layer.mask 的使用
a.layer.mask = b.layer;
b 的不透明的部分,会变成a的内容的显示部分。
聊天气泡.png
代码:
UIImageView *girlsImage = [[UIImageView alloc]initWithFrame:CGRectMake(30, 100, 192, 108)];
girlsImage.image = [UIImage imageNamed:@"zisehua.jpg"];
[self.view addSubview:girlsImage];
UIImage *bumble = [UIImage imageNamed:@"bunble.png"];
UIImageView *bumbleImage = [[UIImageView alloc]initWithFrame:girlsImage.frame];
bumbleImage.image = [bumble stretchableImageWithLeftCapWidth:30 topCapHeight:30];
CALayer *layer = bumbleImage.layer;
layer.frame = girlsImage.bounds;
girlsImage.layer.mask = layer;