I would like to add some rounded corners to all of the UIImageViews in my project. I have already got the code working, but am having to apply it to every image; should I subclass UIImageView to add this? If so, can someone give me some pointers as to how to do this?
Here is the code
- (void)viewDidLoad {
[super viewDidLoad];
NSString *mainpath = [[NSBundle mainBundle] bundlePath];
welcomeImageView.image = [UIImage imageWithContentsOfFile:[mainpath stringByAppendingString:@"/test.png"]];
welcomeImageView.layer.cornerRadius = 9.0;
welcomeImageView.layer.masksToBounds = YES;
welcomeImageView.layer.borderColor = [UIColor blackColor].CGColor;
welcomeImageView.layer.borderWidth = 3.0;
CGRect frame = welcomeImageView.frame;
frame.size.width = 100;
frame.size.height = 100;
welcomeImageView.frame = frame;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…