呈现图像裁剪界面 [英] Presenting an image cropping interface

查看:84
本文介绍了呈现图像裁剪界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个UI在iPhone操作系统中裁剪图像,怀疑我要努力的事情。我的目标是Tapbots两人对Pastebot所做的一切。在该应用程序中,他们调暗源图像,但提供了一个可移动和可调整大小的裁剪视图,您正在裁剪的图像是在可缩放的滚动视图;当您调整大小或移动底层图片时,裁剪视图会适当调整。

I'm trying to engineer a UI for cropping images in iphone OS and suspect I'm going about things the hard way. My goal is pretty much what the Tapbots duo have done with Pastebot. In that app, they dim the source image but provide a movable and resizable cropping view and the image you're cropping is in a zoomable scrollview; when you resize or move the underlying image, the cropping view adjusts appropriately.

我嘲笑了一个复合图像,这将给我的感觉,与我如何我目前有我的视图层次结构设置。

I mocked up a composite image which will give a sense of the design I'm after, along with how I presently have my view hierarchy setup.

我开始的方法是以下:UIImageView与要裁剪的图像是在scrollview中,一个纯黑色填充和适当的透明度/ alpha设置的UIView添加在imageview前面。然后我使用一个自定义UIView,它是一个更高级别的scrollview的兄弟,它实现了drawRect:方法,并且大部分调用CGImageCreateWithImageInRect来获取图像的位图匹配裁剪视图的位置的部分,并绘制到视图控制器中的CGContext。

The approach I've started with is the following: UIImageView with the image to crop is in a scrollview, a plain UIView with black fill and suitable transparency/alpha setting is added in front of the imageview. I then use a custom UIView which is a sibling to the scrollview at a higher level, which implements the drawRect: method and for the most part calls CGImageCreateWithImageInRect to get the portion of the image's bitmap that matches the position of the cropping view and draws that to the CGContext.

我使用UIScrollViewDelegate方法跟踪滚动并将这些更改传递到自定义裁剪UIView,因此它保持与滚动内容同步偏移。这很多终于工作。但是试图保持同步作为scrollView zoomScale更改是我想我应该要求帮助。

in the viewcontroller I'm using the UIScrollViewDelegate methods to track scrolling and passing those changes to the custom cropping UIView so it stays in sync with the scroll contentOffset. That much is finally working. But trying to keep in sync as the scrollview zoomScale changes is when I figured I should ask for help.

寻找建议或指导。我的初始方法看起来比需要更多的工作。

Looking for suggestions or guidance. My initial approach just seems like more work than is required.

这可以通过ImageView中的掩蔽层完成吗?如果是这样,我如何设置跟踪移动和调整裁剪rect?我使用图层的经验是非零的,但迄今为止非常有限。

Could this be done with a masking layer in the ImageView? And if so, how would I setup the tracking for moving and resizing the cropping rect? My experience working with layers is non-nil, but very limited thus far.

推荐答案

Cocoa控制

http:// cocoacontrols。 com / platforms / ios / controls / imagecropper

这篇关于呈现图像裁剪界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆