iOS rounded corner UIImage with border

Deadly 提交于 2019-12-10 14:49:42

问题


Is there a way to make my image appear like this (rounded corners and with a light border).

I'm thinking of creating a white mask that has the middle transparent to place on top, would that work?


回答1:


You can accomplish this, but instead of editing your UIImage, just do this in your UIImageView.

First, add the QuartzCore header

#import <QuartzCore/QuartzCore.h>

And then, edit the properties below, as you wish.

imageView.layer.cornerRadius = 5.0;
imageView.layer.borderColor = [[UIColor grayColor] CGColor];
imageView.layer.borderWidth = 2.0;
imageView.layer.masksToBounds = YES;



回答2:


You're going to want to look at the QuartzCore docs, specifically the cornerRadius, borderColor and borderWidth properties within CALayer.



来源:https://stackoverflow.com/questions/17959931/ios-rounded-corner-uiimage-with-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!