SHOW:
|
|
- or go back to the newest paste.
| 1 | #import <UIKit/UIKit.h> | |
| 2 | @interface TopView : UIView {
| |
| 3 | ||
| 4 | } | |
| 5 | @end | |
| 6 | ||
| 7 | #import "TopView.h" | |
| 8 | #import <QuartzCore/QuartzCore.h> | |
| 9 | ||
| 10 | @implementation TopView | |
| 11 | - (id)initWithFrame:(CGRect)frame {
| |
| 12 | ||
| 13 | self = [super initWithFrame:frame]; | |
| 14 | ||
| 15 | if (self) {
| |
| 16 | // Initialization code. | |
| 17 | } | |
| 18 | return self; | |
| 19 | } | |
| 20 | ||
| 21 | ||
| 22 | - | - (void)drawRect:(CGRect)rect |
| 22 | + | - (void)drawRect:(CGRect)rect{
|
| 23 | - | {
|
| 23 | + | |
| 24 | float borderSize = 5.0f; | |
| 25 | ||
| 26 | //draw the top border | |
| 27 | CGContextRef context = UIGraphicsGetCurrentContext(); | |
| 28 | CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); | |
| 29 | CGContextFillRect(context, CGRectMake(0.0f,0.0f, self.frame.size.width, borderSize)); | |
| 30 | ||
| 31 | //draw the right border | |
| 32 | CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); | |
| 33 | CGContextFillRect(context, CGRectMake(0.0f,0.0f, borderSize,self.frame.size.height)); | |
| 34 | ||
| 35 | //draw the left border | |
| 36 | CGContextSetFillColorWithColor(context, [UIColor blueColor].CGColor); | |
| 37 | CGContextFillRect(context, CGRectMake(self.frame.size.width - borderSize,0.0f, borderSize,self.frame.size.height)); | |
| 38 | } | |
| 39 | - (void)dealloc {
| |
| 40 | [super dealloc]; | |
| 41 | } | |
| 42 | @end |