cgaffinetransform

CGAffineTransform concatenation: appropriate order of transformations

橙三吉。 提交于 2019-12-25 18:42:59
问题 I know that whenever we want to apply a series of transform at once to a point, we have to specify the sequence in the opposite direction to what we want to perceive. If I want to translate( T ) and then rotate( R ) a point x we need to end with a concatenation matrix RT , then every point is transformed as (RT)x . Apple Transform documentation shows that CGAffineTransform work as a transpose version of the above expression. i.e instead of transform a points as Ax for A being any transform

How to use Rotation and Translation for an Image simultaneously in iPhone?

北慕城南 提交于 2019-12-25 09:59:25
问题 I using CGAffineTransformMakeRotation for the Rotation of an Image and CGAffineTransformMakeTranslation for the Translation of an Image. This is my code: -(void)rotateTranslate { r++; CGAffineTransform transform = CGAffineTransformMakeRotation(r); imageView.transform = transform; x++; y++; CGAffineTransform transform1=CGAffineTransformMakeTranslation(x,y); imageView.transform= transform1; [self performSelector:@selector(rotateTranslate) withObject:self afterDelay:0.2]; } My Problem is the

CGContext transformation, to extract rotated rect

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:49:15
问题 My intention is to write a function which can extract a rotated rectangular portion of a larger image. That rotated rectangular portion is described with a center point (from 0,0 to full image width/height) a size, and a rotation angle. I worry that I'm not understanding something about CGContexts. I know that after a rotation, my coordinate space is rotated. This function always works if the angle is 0 and appears to be correct if the angle is small. However, as the angle increases,

iphone : How to rotate a rectangle image with touch events?

爱⌒轻易说出口 提交于 2019-12-25 03:53:41
问题 transform a square image or round image is easy to do... But what if a rectangle image ??? This is the image I want to transform with touch event . The circle center is (30 , 236) , if I touch any place on the screen Imageview will transform the arrow to my touch point. But the circle center still the same place . I try to transform the image use a test angle It will become like this ... How to adjust the image ? Also the code is here - (void)viewDidLoad { CGRect arrowImageRect = CGRectMake

UIView animation with CGAffineTransformMakeScale changes size instantly with decimal number

北城以北 提交于 2019-12-24 04:23:08
问题 - (void)startAnimation { //reverse - shrinking from full size if (_reversed == YES) { //self.transform = CGAffineTransformMakeScale(1.0, 1.0); [UIView animateWithDuration:1.0f delay:0.0f options:UIViewAnimationOptionCurveLinear animations:^{ self.transform = CGAffineTransformMakeScale(0.1, 0.1); //this line does it instantly self.alpha = 0; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } else { //non reverse - expanding from middle self.transform = CGAffineTransformMakeScale

Rotating UITextView programmatically

女生的网名这么多〃 提交于 2019-12-24 04:18:08
问题 There is a weird problem, if you create a UITextView and rotate it right after creating it, some lines or characters will not be visible! Try this: myTextView.font = UIFont.boldSystemFontOfSize(20) myTextView.text = "Hello world wht the hell\nhello mrs lorem ipum!" let maxsize = CGSizeMake(700, 700) let frame = myTextView.sizeThatFits(maxsize) myTextView.frame = CGRectMake(200, 200, frame.width, frame.height) view.addSubview(myTextView) myTextView.transform = CGAffineTransformMakeRotation

Scale affine transformation scaling differently on iOS7 and iOS8/iOS9 in Swift

被刻印的时光 ゝ 提交于 2019-12-23 19:14:07
问题 I am using scale affine transformations in Swift and have noticed CGAffineTransformMakeScale does not work the same on all iOS versions. To demonstrate the differences, I have created a new Xcode 7 project, set up three test boxes on the Xcode Storyboard running on an iOS7 device, iOS8 simulator and iOS9 simulator. Box A - has no constraints applied and is positioned centre top on the Storyboard Box B - has height and width set along with center horizontal and center vertical alignment

How to compute the frame of a UIView before the transform?

女生的网名这么多〃 提交于 2019-12-23 17:43:03
问题 Question I have a UIView and I apply to it a CGAffineTransform . I would like to be able to know the frame of the view if the transform had not be applied . I am looking for a (simple) solution that handles the case where the transform is the "zero-transform" (which is not invertible). My attempt The following does not work for the "zero-transform", I guess. CGRect result ; CGAffineTransform transform = self.transform ; result = CGRectApplyAffineTransform(self.frame, CGAffineTransformInvert

Combine translation, alpha and scale animations in swift3

依然范特西╮ 提交于 2019-12-23 14:20:20
问题 I'm totally newbies with iOS Swift developement and i try to combine three parameters in a single animations but i don't succeed. I think the solution is here -Apple Dev Core Animation Programming Guide by grouping the animations but being a beginner and after a lot of Internet research i can't find what i'm looking for. What do you think of my code and what is for you the best solution to combine performance and stability. I want to point out that the purpose of this animation is to create

Preventing Subview from Transforming when its Superview Transforms

假如想象 提交于 2019-12-23 02:58:06
问题 I have the following set up. I have a UIView called parentView that holds a UIView called childView . parentView can be rotated and resized using some touch gestures which need to be on the parentView . childView has some drawing code in its drawRect method which needs to updated as the parentView is transformed. I am noticing when I transform the parentView (scale or rotate), childView automatically gets transformed as well. Problem with this is, while I do want the rotate transform to be