#import @interface TopView : UIView { } @end #import "TopView.h" #import @implementation TopView - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code. } return self; } - (void)drawRect:(CGRect)rect{ float borderSize = 5.0f; //draw the top border CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); CGContextFillRect(context, CGRectMake(0.0f,0.0f, self.frame.size.width, borderSize)); //draw the right border CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); CGContextFillRect(context, CGRectMake(0.0f,0.0f, borderSize,self.frame.size.height)); //draw the left border CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); CGContextFillRect(context, CGRectMake(self.frame.size.width - borderSize,0.0f, borderSize,self.frame.size.height)); } - (void)dealloc { [super dealloc]; } @end