美文网首页
UIview、UIimageview加圆角同时设置阴影

UIview、UIimageview加圆角同时设置阴影

作者: 崔章强 | 来源:发表于2018-12-07 16:34 被阅读0次
    @implementation cuiview
    
    
    -(instancetype)initWithFrame:(CGRect)frame
    {
        self = [super initWithFrame:frame];
        if (self) {
            self.backgroundColor = [UIColor orangeColor];
            //v.layer.masksToBounds=YES;这行去掉
            self.layer.cornerRadius = 10;
            self.layer.shadowColor = [[UIColor redColor] CGColor];
            self.layer.shadowOffset = CGSizeMake(0, 0);
            self.layer.shadowOpacity = 0.5;
            self.layer.shadowRadius = 5;
            
        }
        return self;
    }
    
        cuiview *cui = [[cuiview alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
        [self.view addSubview:cui];
        
        UIImageView *imageview = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
        imageview.layer.cornerRadius=10;
        imageview.clipsToBounds=YES;
        
        [imageview sd_setImageWithURL:[NSURL URLWithString:@"http://img4.bitautoimg.com/autoalbum/files/20101220/862/13374086240035_1469891_15.JPG"]];
        [cui addSubview:imageview];
    
    

    相关文章

      网友评论

          本文标题:UIview、UIimageview加圆角同时设置阴影

          本文链接:https://www.haomeiwen.com/subject/gjzthqtx.html