Making round corners for a UIImage

2019-07-17 08:32发布

问题:

In my iPhone application I have to show a UIImage with its all four corners curved so that it looks good on the screen. But my image is a rectangular image which cannot be altered at image level as it comes from a third party.

With UIImageView I can set the frame. Using code, how can I modify my UIImage to have rounded corners?

Any clue?

回答1:

try this way:

UIImageView *imageView = ...;
imageView.layer.cornerRadius = 7; // change this value  as per your desire
imageView.clipsToBounds = YES;