Я не могу перехватить функцию инициализации, которая вызывается, когда она создается внутри файла xib.
Я хочу добавить границу к нему, когда он будет создан, чтобы мне не нужно было добавлять его вручную.
.h:
#import <UIKit/UIKit.h>
@interface UITextView (FITAddBorderline)
- (id) init;
- (id) initWithFrame:(CGRect)frame;
@end
.m:
#import "UITextView+FITAddBorderline.h"
@implementation UITextView (FITAddBorderline)
- (id) init
{
self = [super init];
if (self) {
[self addBorderline];
}
return self;
}
- (id) initWithFrame:(CGRect)frame {
self = [super init];
if (self) {
self.frame = frame;
[self addBorderline];
}
return self;
}
- (void) addBorderline {
//To make the border look very close to a UITextField
[self.layer setBorderColor:[[[UIColor grayColor] colorWithAlphaComponent:0.5] CGColor]];
[self.layer setBorderWidth:2.0];
//The rounded corner part, where you specify your view's corner radius:
self.layer.cornerRadius = 5;
self.clipsToBounds = YES;
}
@end