#import "MyView.h"
@implementation MyView
- (void)drawRect:(CGRect)rect
{
//上下文
CGContextRef text = UIGraphicsGetCurrentContext();
//对上下文进行操作
CGContextTranslateCTM(text, 150, 0);// 平移上下文
CGContextScaleCTM(text, 0.5, 0.5);//缩小
CGContextRotateCTM(text, M_PI_4);//旋转
//路径:画圆
UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 200, 100)];
//将路径加到上下文
CGContextAddPath(text, path.CGPath);
//填空渲染
CGContextFillPath(text);
}
@end
转载于:https://my.oschina.net/cgphp/blog/418645