给ImageView添加约束后,在裁圆角作为头像,在ios9无效bug

时间:2015-09-25 21:41:55   收藏:0   阅读:1402

通常方法在layoutSubviews,写这些,可以对付约束情况下的圆角,可是在ios9不起作用了,我用的是9.1测试版,解决办法是subclass,UIImageView,然后看后面代码

-(void)layoutSubviews

{

    [super layoutSubviews];

    [self layoutIfNeeded];

        _imageViewIcon.layer.cornerRadius = _imageViewIcon.width/2;

        _imageViewIcon.layer.masksToBounds = YES;

       _imageViewIcon.clipsToBounds = YES;

//    _imageViewIcon.layer.opaque = NO;

 

    [_imageViewIcon setClipsToBounds:YES];

}

subclass:

-(instancetype)init

{

    if (self = [super init]) {

    

    }

 

    return self;

}

-(void)layoutSubviews

{

    [super layoutSubviews];

    [self layoutIfNeeded];

    

    self.layer.masksToBounds = YES;

    self.layer.cornerRadius = self.width*0.5;

 

 

 

}

原文:http://www.cnblogs.com/daaiwusehng/p/4839337.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!