ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

iOS镂空UIView

| Comments

如果想把UIView挖空一块,使用遮罩图。

效果图如下:

image

示例代码如下:

1
2
3
4
5
6
7
8
9
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];

    CALayer *mask = [CALayer layer];
    mask.frame = self.maskView.bounds;
    mask.contents = (id)[[UIImage imageNamed:@"mask"] CGImage];
    _maskView.layer.mask = mask;
    _maskView.layer.masksToBounds = YES;
}

代码见链接

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory