uigraphicscontext

How to save UIImage after Editing with Pan, Rotate and Pinch Gesture

跟風遠走 提交于 2021-02-07 19:43:35
问题 I'm trying to implement edit image using UIPanGesture, UIRotateGesture, and UIPinchGesture. After editing, I wish to save edited UIImage. I'm done edit image functionality. But I don't know How to save exactly perfect like native iOS Camera App. Pan Gesture is working fine. My problem is Rotate and Scale. How to set center anchor point of UIImage? When I saved UIImage from transform information then the result of UIImage is looks different because Rotate and Scale, then It always applied

How do I draw an NSAttributedString rotated around a specific point?

二次信任 提交于 2020-01-30 08:17:05
问题 I'm woking on a project were I have to draw strings of text in a UIView. The problem is not drawing the Strings, but rotating them. I want the text to be drawn just above and at the same angle as the red line. Check illustration below: illustration example: Here is the code... (PS. All irrelevant code is removed) class DrawView: UIView { override func draw(_ rect: CGRect) { let context = UIGraphicsGetCurrentContext()! // Adding a line here. context.move(to: CGPoint(x: 290, y: 650)) context

Issue capturing selected views as they appear on screen with renderInContext in Swift

微笑、不失礼 提交于 2020-01-23 09:44:08
问题 I have three views on my storyboard, viewA , viewB , viewC . I’m trying to screen capture only two views as they appear on screen in their current place, viewB and viewC . The trouble is, when I render them, the resulting image captured shows viewB and viewC in incorrect locations, the position of the views change moving top left (0, 0), see image. How can I correct the code below so that I can capture the views viewB and viewC exactly as they are positioned on the view using the

How to fill Imageview letter / character in Swift?

荒凉一梦 提交于 2020-01-16 07:41:08
问题 I am a beginner in iOS. I am working on the character fill up of UIImageView . Like if image show "R" user need to draw/fill "R" Character then next character show. How can I achieve that? Example : Below snippet of code try from my side (in Objective - C): CGPoint currentPoint = pointB; if ([UIScreen.mainScreen respondsToSelector:@selector(scale)]) { UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, UIScreen.mainScreen.scale); } else { UIGraphicsBeginImageContext(self.frame.size);

How to make text appear in centre of the image?

五迷三道 提交于 2020-01-03 05:50:10
问题 I want to add a text on an image, and I'm able to do it as shown in below code. func textToImage(drawText: NSString, inImage: UIImage, atPoint:CGPoint)->UIImage{ // Setup the font specific variables var textColor: UIColor = UIColor.redColor() var textFont: UIFont = UIFont(name: "AmericanTypewriter", size: 75)! let textStyle = NSTextEffectLetterpressStyle //Setup the image context using the passed image. UIGraphicsBeginImageContext(inImage.size) let textFontAttributes = [ NSFontAttributeName:

Issue With drawViewHierarchyInRect: afterScreenUpdates while taking snapshot

折月煮酒 提交于 2020-01-02 00:10:21
问题 I am facing problem with taking snapshot of UIView along with CAEmitterLayer . Below is the code which I am using for taking snapshot: here editingView is my UIView : UIGraphicsBeginImageContextWithOptions(editingView.bounds.size, NO, 0.0); [editingView drawViewHierarchyInRect:editingView.bounds afterScreenUpdates:YES]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Please go through the below links for Gif Images Link For For afterScreenUpdates:NO

Sketch On UIView Within UIScrollView

懵懂的女人 提交于 2019-12-25 04:23:20
问题 I am having an issue when trying to sketch on a UIView that is a child view in a UIScrollView . The problem occurs when you try to sketch on the UIView after it's been zoomed or scrolled on. It seems my sketch code (shown below) does not take into account the zoom or scale of the UIView within the UIScrollView because the lines blur and don't show up where they should. Please let me know if there is something that can be done to my code or provide another solution. - (void)touchesBegan:(NSSet

CALayer renderInContext iOS7

Deadly 提交于 2019-12-22 17:39:05
问题 I'm rendering multiple layers to get one final image. One of the images contains a face, and another one contains a background with a transparent gradient around the face so that the real background is hidden. In iOS6 it works perfectly but it is creating a weird effect with the transparent gradient in iOS7. The code: CGRect rect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [faceImageView.layer renderInContext

Clip UIImage to UIBezierPath (not masking)

ε祈祈猫儿з 提交于 2019-12-22 08:25:04
问题 I'm trying to clip a UIImage based on a given UIBezierPath , but the resulting image retains the original shape and size. I want the shape and size to resemble the path, i.e. the visible content of the new image. Take a look at this following example: The following is the code I am using to mask an image given a path: func imageByApplyingClippingBezierPath(_ path: UIBezierPath) -> UIImage { UIGraphicsBeginImageContextWithOptions(CGSize( width: size.width, height: size.height ), false, 0.0)