iOS简单的画线(UIImageVIew方式)
2012-07-31 16:32
375 查看
#import <UIKit/UIKit.h> @interface ViewController : UIViewController { UIImageView *mImageView; } @end
#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; mImageView = [[UIImageView alloc] initWithFrame:self.view.frame]; mImageView.backgroundColor = [UIColor grayColor]; [self.view addSubview:mImageView]; UIGraphicsBeginImageContext(mImageView.frame.size); [mImageView.image drawInRect:CGRectMake(0, 0, mImageView.frame.size.width, mImageView.frame.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 15); CGContextSetAllowsAntialiasing(UIGraphicsGetCurrentContext(), YES); CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [[UIColor blueColor] CGColor]); CGContextBeginPath(UIGraphicsGetCurrentContext()); CGContextMoveToPoint(UIGraphicsGetCurrentContext(), 100, 100); CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), 200, 200); CGContextStrokePath(UIGraphicsGetCurrentContext()); mImageView.image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } - (void)viewDidUnload { [super viewDidUnload]; // Release any retained subviews of the main view. } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); } @end
相关文章推荐
- iOS图片的填充方式UIImageView(contentMode)有什么不同
- iOS UIImageview实现简单动画
- iOS uiimage和其它view 设置圆角的方式
- ios中UIImageView展现图片的不同处理方式
- iOS UIImageView的简单使用
- IOS中UIImageView方法实现简单动画
- iOS图片的填充方式UIImageView(contentMode)有什么不同
- ios中UIImageView展现图片的不同处理方式
- IOS UIImageView轻击手势没有响应
- iOS开发UI篇—UITableview控件简单介绍
- iOS——简单的自定义view
- iOS-UIImageView常用操作
- iOS 之UIImageView实现图片的移动和缩放
- ios MKMapView的简单使用
- iOS 第四章之UIImageView
- iOS--webView的简单使用
- iOS有关图片处理的总结 (一)------UIImage的加载方式
- iOS笔记------UITableView简单解析
- iOS - UIImageView 的contentMode属性,以及图片拉伸stretchableImageWith
- 获取View宽高的几种方式及View和ViewGroup测量的简单实现