·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> IOS开发 >> IOS绘图——简单三角形

IOS绘图——简单三角形

作者:佚名      IOS开发编辑:admin      更新时间:2022-07-23

#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