菜单

金沙网上娱乐:objective C达成One plusLogo的水晶立体效果

2019年5月13日 - www6165com
- (void)viewDidLoad {
    [super viewDidLoad];
    UIGraphicsBeginImageContext(icon.bounds.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    const CGFloat components[4] = {0.0,0.4,0.0,1.0};
    CGContextSetFillColor(ctx, components);
    CGContextFillRect(ctx, CGRectMake(0, 0, icon.bounds.size.width, icon.bounds.size.height));
    UIImage *background = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImage *image = [UIImage imageNamed:@"icon.png"];
    UIImage *mask = [UIImage imageNamed:@"IconBase.png"];
    UIImage *roundCorner = [UIImage imageNamed:@"round-corner.png"];
    icon.image = image;
    CALayer* subLayer = [[CALayer layer] retain];
    subLayer.frame = icon.bounds;
    subLayer.contents = (id)[background CGImage];
    CALayer* maskLayer = [[CALayer layer] retain];
    maskLayer.frame = icon.bounds;
    maskLayer.contents = (id)[mask CGImage]; 
    [subLayer setMask:maskLayer];
    [[icon layer] addSublayer:subLayer];
    CALayer* roundCornerLayer = [[CALayer layer] retain];
    roundCornerLayer.frame = icon.bounds;
    roundCornerLayer.contents = (id)[roundCorner CGImage];
    [[icon layer] setMask:roundCornerLayer];
    [maskLayer release];
    [subLayer release];
    [roundCornerLayer release];
}

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图