从UIImageView中删除行
我在UIImageView上绘制了一条直线。 现在,如果用户点击它,我想要删除那条线。 这是我在图像上画一条线的代码。
- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender { if (sender.state == UIGestureRecognizerStateEnded) { CGPoint location=[sender locationInView:imageView]; CGPoint contextLocation = CGPointMake(location.x*imageView.image.size.width/imageView.frame.size.width, location.y*imageView.image.size.height/imageView.frame.size.height); UIColor * linearcolor=[UIColor blueColor]; CGSize imagesize=imageView.image.size; UIGraphicsBeginImageContext(imageView.image.size); [imageView.image drawAtPoint:CGPointMake(0, 0)]; CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetLineWidth(context, 2.0); CGPoint location2=CGPointMake(300, 400); CGContextBeginPath(context); CGContextMoveToPoint(context, contextLocation.x, contextLocation.y); CGContextAddLineToPoint(context, location2.x, location2.y); CGContextAddQuadCurveToPoint(context, contextLocation.x, contextLocation.y, location2.x, location2.y); CGContextSetLineCap(context, kCGLineCapRound); if([removeLine isEqualToString:@"true"]) { CGContextClearRect (context, CGRectMake(location2.x, location2.y, contextLocation.x, contextLocation.y)); CGContextFlush(context); } CGContextSetStrokeColorWithColor(context,[linearcolor CGColor]); CGContextStrokePath(context); UIImage * newImage=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); removeLine=@"true"; imageView.image=newImage; } }
- 如何解决'NSUnknownKeyException'… setValue:forUndefinedKey:]:…不符合键值编码
- 来自摄像机video的数据返回零
- 使用popViewControllerAnimated时,按钮色调会改变颜色
- Xcode 7.2 bug:找不到-lGoogleAnalyticsServices的库
- 为什么故事板的UI元素不显示UIViewController在Xcode 6?
- 如何在Firebase完成用户数据下载后重新加载UITableView数据?
- 目前正在进行演示? 试图显示一个新的看法后,Facebookloginparsing。
- 在UIWebview中加载string
- 监视MKMapView重绘事件