使用 objective-c 为照片添加注释
Annotate photos using objective-c
我想为 iOS 应用程序的照片添加注释,我正在搜索是否存在可以帮助我设置基础的库。
基本上我希望实现类似 skitch 应用程序的功能:https://itunes.apple.com/us/app/skitch-snap.-mark-up.-send./id490505997?mt=8
我正在开发的功能要求应用程序用户拍摄图片、突出显示图片的特定区域并对其进行评论。
感谢任何有关如何进行的线索。
谢谢。
试试这个,希望对你有帮助
#pragma mark touches stuff...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
lastTouch = [touch locationInView:imageView]; // This is your view
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:imageView];
CGColorRef strokeColor = [UIColor brownColor].CGColor;
UIGraphicsBeginImageContext(imageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context,10);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [UIColor brownColor].CGColor);
CGContextSetBlendMode(context,kCGBlendModeDarken );
CGContextBeginPath(context);
CGContextMoveToPoint(context, lastTouch.x, lastTouch.y);
CGContextAddLineToPoint(context, currentTouch.x, currentTouch.y);
CGContextStrokePath(context);
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastTouch = [touch locationInView:imageView];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
lastTouch = [touch locationInView:imageView];
}
BugShot 的创建者 Marco Arment 开源了 BugShotKit,让开发人员可以轻松添加对注释的支持。您可以在此处查看项目 https://github.com/marcoarment/BugshotKit
我查看了 SkitchSnap 使用的所有包,这些是您应该查看的基本库:
https://github.com/mattgemmell/MGImageUtilities
https://github.com/coryalder/UIImage_Resize
他们还有许多您应该查看的其他库。
示例:要获得灰色效果,用户登录,转换 SVG 对象,测试..
我想为 iOS 应用程序的照片添加注释,我正在搜索是否存在可以帮助我设置基础的库。
基本上我希望实现类似 skitch 应用程序的功能:https://itunes.apple.com/us/app/skitch-snap.-mark-up.-send./id490505997?mt=8
我正在开发的功能要求应用程序用户拍摄图片、突出显示图片的特定区域并对其进行评论。
感谢任何有关如何进行的线索。
谢谢。
试试这个,希望对你有帮助
#pragma mark touches stuff...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
lastTouch = [touch locationInView:imageView]; // This is your view
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:imageView];
CGColorRef strokeColor = [UIColor brownColor].CGColor;
UIGraphicsBeginImageContext(imageView.frame.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetLineWidth(context,10);
CGContextSetStrokeColorWithColor(UIGraphicsGetCurrentContext(), [UIColor brownColor].CGColor);
CGContextSetBlendMode(context,kCGBlendModeDarken );
CGContextBeginPath(context);
CGContextMoveToPoint(context, lastTouch.x, lastTouch.y);
CGContextAddLineToPoint(context, currentTouch.x, currentTouch.y);
CGContextStrokePath(context);
imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastTouch = [touch locationInView:imageView];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
lastTouch = [touch locationInView:imageView];
}
BugShot 的创建者 Marco Arment 开源了 BugShotKit,让开发人员可以轻松添加对注释的支持。您可以在此处查看项目 https://github.com/marcoarment/BugshotKit
我查看了 SkitchSnap 使用的所有包,这些是您应该查看的基本库: https://github.com/mattgemmell/MGImageUtilities https://github.com/coryalder/UIImage_Resize
他们还有许多您应该查看的其他库。 示例:要获得灰色效果,用户登录,转换 SVG 对象,测试..