cgaffinetransform

Rotate (angle) a UIView, using User Defined Runtime Attributes

徘徊边缘 提交于 2019-12-22 04:01:54
问题 Is it possible to rotate a UIView or UIImageView, say 10 or 15 degrees, actually using User Defined Runtime Attributes? Or can it only be done in code? (Note .. I mention "angle" and "by degrees" for the sake of google; it can get mixed-up with the idea of "rotating" for device orientation change.) Alternately, could you perhaps subclass UIView in such a way that, a User Defined Runtime Attribute would be exposed, which does just this? (I'm rusty :/ ) 回答1: You can use layer.transform.rotation

How to smoothen the edges of a UIImageView in iOs [duplicate]

南笙酒味 提交于 2019-12-21 23:31:32
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Any quick and dirty anti-aliasing techniques for a rotated UIImageView? I wanted to change the angle of an UIImageView in my iPhone and app i used the following code: previewImg.transform = CGAffineTransformMakeRotation(atan2(y2-y1,x2-x1)); and I got it working and the image is below. In the image, the edges of the image is not smooth. Is there any way to smoothen the edges? 回答1: This has been asked before,

CTM transforms vs Affine Transforms in iOS (for translate, rotate, scale)

末鹿安然 提交于 2019-12-21 23:08:16
问题 I read through the Transforms documentation in the Quartz 2D Programming Guide. In it there appears to be two ways to make transformations. One way is through modifying the Current Transformation Matrix (CTM). It has methods like the following: CGContextTranslateCTM CGContextRotateCTM CGContextScaleCTM The other way is to use Affine transforms. It has methods like the following: CGAffineTransformTranslate CGAffineTransformRotate CGAffineTransformScale The docs state The affine transform

iOS: Mirror content on screen

天涯浪子 提交于 2019-12-21 07:05:19
问题 I would like to know if it is possible to flip the contents of a UIView within the same device; meaning not to an external monitor but on the device itself. I have searched a bit on google, but all I can find is to external screens. 回答1: You can use CGAffineTransformMakeScale with negative values. Like: CGAffineTransformMakeScale(1.0, -1.0); This can be applied on the view by: //Mirror top to bottom view.transform = CGAffineTransformMakeScale(1.0, -1.0); or //Mirror Left to Right view

Gesture recognizers and auto-layout in iOS6, scaling from the center

删除回忆录丶 提交于 2019-12-21 04:29:32
问题 This gesture recognizer code below, which normally would scale a view from the center, does not when auto-layout is enabled in iOS6. The view seems to scale from it's origin when auto layout is enabled. Other affine transformations (particularly scale and rotate) are also not working as I expected. Anyone have this issue, or can enlighten me to the right way to handle this? - (IBAction)handlePinch:(UIPinchGestureRecognizer *)recognizer { recognizer.view.transform = CGAffineTransformScale

CGAffineTransform Reset

可紊 提交于 2019-12-20 16:13:03
问题 3I have an image that gets manipulated by touch. Lets say its an image of an arrow that points up. After it's been rotated 180 degrees, so the arrow is pointing down now, I want to reset CGAffineTransform properties so that it thinks now its turned back to 0 degrees. I want this because I have to translate, rotate, scale etc whether the image's angle is 0 OR 180. Thanks in advance. EDITED Ater 5 replies: Hmm, I am not sure if any of these answers do what I wanted to. I apologize for not being

CGAffineTransform Reset

馋奶兔 提交于 2019-12-20 16:11:28
问题 3I have an image that gets manipulated by touch. Lets say its an image of an arrow that points up. After it's been rotated 180 degrees, so the arrow is pointing down now, I want to reset CGAffineTransform properties so that it thinks now its turned back to 0 degrees. I want this because I have to translate, rotate, scale etc whether the image's angle is 0 OR 180. Thanks in advance. EDITED Ater 5 replies: Hmm, I am not sure if any of these answers do what I wanted to. I apologize for not being

How do I use CGAffineTransformMakeScale and Rotation at once?

烈酒焚心 提交于 2019-12-20 12:07:11
问题 ((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeRotation(1.57*2); ((UIImageView*)[dsry objectAtIndex:0]).transform = CGAffineTransformMakeScale(.5,.5); Just one of these works at a time. How can I save a transformation and then apply another? Cheers 回答1: To expand upon what Peter said, you would want to use code like the following: CGAffineTransform newTransform; newTransform = CGAffineTransformMakeRotation(1.57*2); ((UIImageView*)[dsry objectAtIndex:0]).transform =

Applying transform to UITextView - prevent content resizing

谁都会走 提交于 2019-12-20 10:27:08
问题 When I apply a rotation transform to a UITextView and then click inside to begin editing, it appears that the content size is automatically being made wider. The new width of the content view is the width of the rotated view's bounding box. For example, given a text box of width 500 and height 400, and rotated by 30 degrees, the new content width would be: (500 * cos(30)) + (400 * sin(30)) = 633 Or graphically: Interestingly, if you are already editing the text view and THEN apply the

Zoom a rotated image inside scroll view to fit (fill) frame of overlay rect

丶灬走出姿态 提交于 2019-12-20 10:25:18
问题 Through this question and answer I've now got a working means of detecting when an arbitrarily rotated image isn't completely outside a cropping rect. The next step is to figure out how to correctly adjust it's containing scroll view zoom to ensure that there are no empty spaces inside the cropping rect. To clarify, I want to enlarge (zoom in) the image; the crop rect should remain un-transformed. The layout hierarchy looks like this: containing UIScrollView UIImageView (this gets arbitrarily