IOS: create a UIImage or UIImageView with rounded corners

后端 未结 12 750
执笔经年
执笔经年 2020-12-07 07:26

Is it possible create an UIImage or an UIImageView with rounded corners? Because I want take an UIImage and show it inside an UI

12条回答
  •  不思量自难忘°
    2020-12-07 07:58

    Try this to get rounded corners of the image View and also to colour the corners:

    imageView.layer.cornerRadius = imageView.frame.size.height/2;
    imageView.layer.masksToBounds = YES;
    imageView.layer.borderColor = [UIColor colorWithRed:148/255. green:79/255. blue:216/255. alpha:1.0].CGColor;
    imageView.layer.borderWidth=2;
    

    Condition*: The height and the width of the imageView must be same to get rounded corners.

提交回复
热议问题