简体   繁体   中英

array of caLayer in iphone

i want to take the array of CALAYER:-

CALayer *layer3 = [CALayer layer];
    [layer3 setBounds:CGRectMake(0.0f, 0.0f, 10.0f, 10.0f)];
    [layer3 setCornerRadius:5.0f];
    [layer3 setMasksToBounds:YES];
    [layer3 setBackgroundColor:[[UIColor redColor] CGColor]];

    // Center the layer in the view.
    [layer3 setPosition:CGPointMake(x,y)];
[[self.Image layer3] addSublayer:layer3];

By the above way i had made one point in the image. But i want to draw the 10 point in the image. I want to take the arrary of CALAyer. Please help me .How can i take the array of CALAYER.

Thanks in advance

    NSMutableArray *Arr=[[NSMutableArray alloc] init];
    CALayer *layer1 = [CALayer layer];
        [layer1 setBounds:CGRectMake(0.0f, 0.0f, 10.0f, 10.0f)];
        [layer1 setCornerRadius:5.0f];
        [layer1 setMasksToBounds:YES];
        [layer1 setBackgroundColor:[[UIColor redColor] CGColor]];
         [Arr addObject:layer1];
    CALayer *layer3 = [CALayer layer];
        [layer3 setBounds:CGRectMake(0.0f, 0.0f, 10.0f, 10.0f)];
        [layer3 setCornerRadius:5.0f];
        [layer3 setMasksToBounds:YES];
        [layer3 setBackgroundColor:[[UIColor redColor] CGColor]];
        [Arr addObject:layer3];
    CALayer *layer4 = [CALayer layer];
        [layer4 setBounds:CGRectMake(0.0f, 0.0f, 10.0f, 10.0f)];
        [layer4 setCornerRadius:5.0f];
        [layer4 setMasksToBounds:YES];
        [layer4 setBackgroundColor:[[UIColor redColor] CGColor]];
        // [Arr addObject:layer4]; Center the layer in the view.

now take Individual Layer From Array... I Hope It Will Help To You Try Once

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM