I have a CATextLayer as sublayer of CALayer. The CALayer rotates and so does the CATextLayer as expected. The problem is that that CATextLayer should always face upside down (according to UIInterfaceOrientationPortrait). I have tried rotating the CATextLayer but it shifts positions and moves out of the bounds of it's parent layer. I just want to rotate the CATextLayer such that it is always aligned to the current interface orientation no matter what is the angle of it's parent layer.
I have tried the answer in this thread but nothing happens CATextLayer rotate?
Related
I have an Image View and I need to be able to pinch-zoom it, scroll it when it is zoomed and also rotate it with two-finger.
Initially I used a scrollView and added ImageView to it. but ImageView wasnt getting rotation gestures as ScrollView was intercepting them.
So I added the gesture to the ScrollView started rotating the scrollView itself.
Things work fine but rotated scrollView doesn't look good.
So I made the ScrollView get the rotation gesture but rotated the imageView in it instead of ScrollView.
But Now, the problem is If I rotate the image and then zoom and again try to rotate, previous rotation is lost and same when I rotate the previous zoom level is lost.
How should I go about it ? Is the scrollView unnecessary ?
I am adding a subview on a rotated superview and want it to clip to the superviews bounds.
I know that the bounds are the rectangle around the rotated view and by knowing that I DON'T want to clip it to the superviews bounds but I want it to clip at the actual borders of the rotated superview.
How is that done?
I have a UIImageView which is inside another UIView.
I rotate the UIImageView with something like:
object.transform=CGAffineTransformMakeRotation(angle)
When the outer UIView is not rotated, and can use CGAffineTransformMakeRotation to rotate the UIImageView, and it works properly.
However, When the outer UIView is rotated, and I then rotate the UIImageView (non-zero "angle" above) - the UIImageView appears "squashed" or "flattened".
This seems to constantly get worse and worse as it is rotated through different angles.
Why is this happening? Is the outer UIView modifying the transformation matrix that I am then modifying again by explicity setting it?
How can I rotate a UIImageView within a rotated UIView and have it just rotate correctly?
Maybe your UIIamgeView is autoresized by it's superview.
You can try disable the autoresizing ability by setting:
imageView.autoresizingMask = UIViewAutoresizingNone;
or if you just do not want iOS to automatically change the size of your imageView but still want it to automatically set the position for you, you can call:
imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin;
Tell me if you still have problem.
Antialiasing is the process whereby a view’s edges are blended with the colors of the layer below it. Antialiasing for view edges can be enabled systemwide by setting the UIViewEdgeAntialiasing flag in your app’s info.plist, but as the documentation warns, this can have a negative impact on performance (because it requires Core Animation to sample pixels from the render buffer beneath your layer in order to calculate the blending).
Renders with edge antialisasing = YES
I got a UIView which contains a UIBezierPath. (this path is used to draw a shape in drawRect:).
Image of my setup (Blue is the UIView with the drawn shape, Red is the shape of the UIBezierPath (found by trial-error)).
Everything works fine!
but when i rotate the UIView the path does not rotate (but it draws correctly):
As you can see it is no longer updated and in sync with the UIView.
I use CGAffineTransformMakeRotation to rotate the UIView so i thought that i could do the same transformation on the UIBezierPath ([UIBezierPath applyTransform]), but this makes the beziepath disappear (i was not able to find it in the view). still drawing correctly…
any ideas?
best regards
Kristian
Could you try by creating a Container view (UIView) and use it as the parent view for both of your shapes (UIView & UIBezierPath).
Then Apply the Rotation/Animation on only Container View (Parent view).
I a have a following line of code invoked after a touch gesture has completed:
CGRect parentBounds = self.view.bounds;
CGRect parentFrame = self.view.frame;
when iPad is placed in a vertical way both parentFrame and parentBounds have similar dimensions of w:768 h:1004 (or something close to that), but when I rotate parentBounds is 1024x748 while parentFrame is 768x1024.
Is this behavior normal? I thought I understood the concepts beetwen frames and bounds (and how they relate to each other)... but now I am really confused.
Could anyone explain what is happening with frame and bounds of a window (superview) when rotation occurs?
The window does not change orientation; the root view does. It does this by applying a view transform (self.view.transform). You're not supposed to call frame if transform is not CGAffineTransformIdentity.
This is not a complete answer, but might help if you don't get something better: When the device is rotated, the top-level window's frame does not change. Instead, a transform gets applied that rotates everything 90 degrees (or 180 degrees), and then the subviews will get resized to fit in the new coordinate system.
From Apple's PhotoScroller sample code:
We have to use our paging scroll view's bounds, not frame, to calculate the page placement. When the device is in landscape orientation, the frame will still be in portrait because the pagingScrollView is the root view controller's view, so its frame is in window coordinate space, which is never rotated. Its bounds, however, will be in landscape because it has a rotation transform applied.
In short, the view's frame is not affected by device rotations, but its bounds is.