CrazyDev CrazyDev - 3 months ago 10
Objective-C Question

IOS: create a UIImage or UIImageView with rounded corners

Is it possible create an

UIImage
or an
UIImageView
with rounded corners? Because I want take an
UIImage
and show it inside an
UIImageView
, but I don't know how to do it.

Answer

Yes, it is possible.
Import the QuartzCore (#import <QuartzCore/QuartzCore.h>) header and play with the layer property of the UIImageView.

yourImageView.layer.cornerRadius = yourRadius;
yourImageView.clipsToBounds = YES;

See the CALayer class reference for more info.