01-calayer Create + proxy settings

Source: Internet
Author: User

////VIEWCONTROLLER.M//01-calayer Create////Created by Mac on 16/4/18.//copyright©2016 Year Mac. All rights reserved.///*1. Position: Determines the relative offset of the current layer's anchor point to the parent view layer coordinates to the origin, finds the anchor position on the current layer, and aligns the two to 2. Draw a straight line trilogy: Create a variable path (pathcreatemutable): Add to Context (Addpath): Start drawing (drawpath) pathway Phase 2: Starting point determination, property setting (line width and color)*/#import "ViewController.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; [Self creatcalayer];}/** * Create Calayer*//*-(void) Creatcalayer {calayer *layer = [Calayer layer]; Layer.bounds = CGRectMake (0, 0, 200, 200); Position and anchor points determine position, bounds determines size//Layer.frame = CGRectMake (0, 0, 200, 200); The Frame property's constraint on the layer is only a size constraint, and the position is determined by anchorpoint Layer.backgroundcolor = [Uicolor Orangecolor].        Cgcolor;        [Self.view.layer Addsublayer:layer];    Layer.position = Cgpointmake (100, 300); Layer.anchorpoint = Cgpointzero;}*/- (void) Creatcalayer {calayer*layer =[Calayer layer]; Layer.bounds= CGRectMake (0,0, $, $);//position and anchor points determine position, bounds determines sizeLayer.backgroundcolor =[Uicolor Orangecolor].    Cgcolor; Layer.anchorpoint=Cgpointzero; Layer.Delegate=Self ;        [Self.view.layer Addsublayer:layer]; [Layer Setneedsdisplay];}/** * Layer proxy method. This method can be called only if the agent is set*/- (void) Drawlayer: (Calayer *) layer Incontext: (cgcontextref) CTX {//NSLog (@ "Hahahha");cgmutablepathref Path= Cgpathcreatemutable ();//1. Draw a line in the layer path getscgpathmovetopoint (Path, NULL, -, -);//2. Starting pointCgpathaddlinetopoint (Path, NULL, Max, Max);//Connection Point//[[Uicolor Yellowcolor] setstroke];Cgcontextsetrgbstrokecolor (CTX,0,1,1,1);//3. Stoke Line ColorCgcontextsetlinewidth (CTX,5);//line widthCgcontextaddpath (CTX, path);//4. Path added to the contextCgcontextdrawpath (CTX, Kcgpathstroke);//5. Draw}

01-calayer Create + proxy settings

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.