Is it possible for a user to draw a dotted line (in a circle) around the bit of the UIImageView
they wish to crop to, and then for the UIImageView
to resize to those points? It's a bit like the lasso/marquee effect in Photoshop:
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
This answers just one part of your question i suppose, but here's an example on how to draw and animate the dotted line (i.e. marching ants effect).
Update: Since iOS 8.x, UIImageView provides a
maskView
property. Just prepare an image with some opaque pixels, create another image view with that mask image, and set this mask image view as the maskView. The opaque pixels in the mask image will be the ones shown in the underlying image..
Original Answer
There's quite a bit to do, but here's a high-level outline:
Create image: A simple idea here is to just ship a black image with your project. It should be sized to match the maximum region a user can select. Read the image into memory (
UIImage imageNamed:
) and set it up as the drawing context by callingUIGraphicsBeginImageContext
.Create path: (see apple docs). When the user starts stroking the region, call
CGContextBeginPath
, then follow user gestures, sampling the touches and adding small segments by callingCGContextMoveToPoint
repeatedly as touchesMoved.Create mask: To turn the path into a mask you want a black background and the path filled with white. If you started with a black image, you just need to do the fill. See the same apple guide about doing that.
Finally, you'll apply this mask to your imageView's image. Here's a decent reference for that.