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);

}

 

 

@end

 


 

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

原文地址:https://www.cnblogs.com/123qw/p/4282717.html