问题描述:

I need to change the UIImageviewr shape to rounded edges, if there is a way I can change this without modifying the code that would be easiest. If your solution is in the code please tell me where I need to put it. Thanks!

网友答案:

You need to put the code in the view controller that owns the image view. But first, for that you're going to need the QuartzCore framework. Add that framework to your project in the Build Phases - Link Binary With Libraries from your target settings. After importing <QuartzCore/QuartzCore.h> in the view controller, you need to actually round those edges by accessing a property called cornerRadius on the UIImageView's layer. To do that:

_myImageView.layer.cornerRadius = 5.0;

That line of code could go in the viewDidLoad method if you want the image to have rounded corners when the view appears. (Or elsewhere if you need something specific)

Good luck!

相关阅读:
Top