#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

 


 

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

相关文章:

  • 2021-12-21
  • 2021-11-04
  • 2021-12-28
  • 2021-11-05
  • 2021-09-30
  • 2023-02-02
  • 2021-04-23
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2023-02-01
  • 2022-12-23
相关资源
相似解决方案