IOS绘图——简单三角形

时间:2023-03-09 13:35:54
IOS绘图——简单三角形

#import <UIKit/UIKit.h>

@interface MyView : UIView

@end

#import "MyView.h"

@implementation MyView

- (instancetype)initWithFrame:(CGRect)frame {

self = [super initWithFrame:frame];

if (self) {

// Initialization code

}

return self;

}

- (void)drawRect:(CGRect)rect {

CGContextRef context = UIGraphicsGetCurrentContext();

CGContextMoveToPoint(context, 75, 10);

CGContextAddLineToPoint(context, 10, 150);

CGContextAddLineToPoint(context, 160, 150);

CGContextClosePath(context);

[[UIColor blackColor] setStroke];

[[UIColor redColor] setFill];

CGContextDrawPath(context, kCGPathFillStroke);

}

IOS绘图——简单三角形

@end


我的****博客地址:http://blog.****.net/qw963895582/article