I've extended UIImageView inorder to create a rounder image view:
#import <QuartzCore/QuartzCore.h>
#import "RoundedImageView.h"
@implementation RoundedImageView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self makeImageViewRounded];
}
return self;
}
-(void) makeImageViewRounded {
self.layer.backgroundColor=[[UIColor clearColor] CGColor];
self.layer.cornerRadius=20;
self.layer.borderWidth=1.0;
self.layer.masksToBounds = YES;
self.layer.borderColor=[[UIColor whiteColor] CGColor];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
@end
In the story board i've connected an UIImageView to my custom RoundedImageView, But it doesn't seems to affect the view, and my code doesn't get called.
How can i make it work that whenever i attach an custom view to my UIView, the custom view will be initialised ?
Override this initializer when creating views from storyboard:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder: aDecoder];
if (self) {
[self makeImageViewRounded];
}
return self;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.