drawing UIImage inside a CGMutablePath
Given a CGMutablePathRef how do I draw a UIImage in it? I know that you can draw it like the following:
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); [scaledImage drawAtPoint:CGPointMake(0, 0)]; CGContextRestoreGState(context);
but I am not sure if I have a path (which is a rectangle with rounded corner) how do I add an image in it?
- iPhone / iOS : Presenting HTML 5 Keyboard for Postal Codes
- Shift Swift Array
- NSPredicate for time interval
- iOS/Cocoa - Design Pattern for Data Model <-> Controller
- How to create static library for iOS without making all symbols public
- Xcode 7 will NOT build a valid Archive from the same project that builds a valid archive in Xcode 6
2 Solutions Collect From Internet About “drawing UIImage inside a CGMutablePath”
When you say “draw within a CGMutablePath” I have to assume you mean “clip to a CGMutablePath.” In that case, you just need to add the path to the current context (
CGContextAddPath() or any of the path-building functions like
CGContextAddLineToPoint()) and then call
CGContextClip(). You can then draw your image in the context with something like
I think that you are choosing the hard way of doing it.
Your approach assumes that you have already got a bitmap and created a bitmap based graphics context. At your place I would just use UIImage’s :
- Closing only the ImagePicker and passing image to ScrollViewController
- Swift: How to handle view controllers for my game
- Installation of an application cannot be performed in MDM
- – with double value produces 0 unexpectedly
- Asynchronous url requests inside dispatch_async
- query & where in Firebase (swift 3)
- When applying a filter to a UIImage the result is upside down
- presentModalViewController in iOS6
- Xcode 4.2. gets stuck “Attaching to myapp” when running
- How to split a string into substrings of equal length
- Swift arrays and contains, how to determine if a collection contains an object or value?
- Error in linking of a static iOS framework to both app's and XCTest targets
- How to Upload video to server from iPhone?
- Realm object as member is nil after saving
- UISegmentedControl only changes text color when revisiting ViewController