#import <UIKit/UIKit.h>
@interface MyView :UIView
@end
#import "MyView.h"
@implementationMyView
- (instancetype)initWithFrame:(CGRect)frame {
self = [superinitWithFrame:frame];
if (self) {
// Initialization code
}
returnself;
}
- (void)drawRect:(CGRect)rect {
CGContextRefcontext = UIGraphicsGetCurrentContext();
CGContextMoveToPoint(context,75,10);
CGContextAddLineToPoint(context,10,150);
CGContextAddLineToPoint(context,160,150);
CGContextClosePath(context);
[[UIColorblackColor] setStroke];
[[UIColorredColor] setFill];
CGContextDrawPath(context, kCGPathFillStroke);
}
@end
我的CSDN博客地址:http://blog.csdn.net/qw963895582/article