I'm have a view-parent with one background image, which scaled to whole parent view. Also in view-parent i need to display some other views. So when i apply rotation to image :
[self.backgroundView setTransform:CGAffineTransformMakeRotation((CGFloat) M_PI)];
It rotates the whole parent view - so other subviews also rotated on 180 degrees
So, how can i apply rotation only to background view without affecting other views?
Well it sounds like your backgroundView has subviews that obviously would be transformed with parent, that's by design. What you need is to make your other views siblings of your background view. Make sure you're adding subviews to backgroundView's superview and not backgroundView itself.
Related
I have UIView with two subView's inside it.
When I apply a CGAffineTransform to zoom the parent view I want only the parent to get zoomed but not its subViews.
If there any way to do this please suggest me.
Thanks in advance.
You might try to apply the inverse transform to each subview. It can be calculated by the inverse of the scale (1.0 / scale) or CGAffineTransformInvert but this is error-prone.
Another solution is to move the subviews outside of the zoomed view to the parent view such that the subviews become siblings of the zoomed view.
I want to flip the whole view to support right to left languages. The problem is my project doesn't use autolayout so I need to perform this flip manually.
In the same time I can't simply flip the parent view because it mirror all the labels and make them unreadable. So I need to flip parent view and some of its subviews. And in the same time I can't flip these subviews because by default they are flipped around their own centers and break the layout.
How to solve this issue?
Okay... so I am getting the hang of iOS, have created a UIView with a combination of widgets (buttons, UITableViews) content and some rendering in drawRect.
The rendering is actually to draw a rounded rectangle within the UIView frame, with circular corners. Then I add this view to my main view.
In the rotation animation, I change the position and aspect ratio of my UIView and called a layout method, and was pleased that it would smoothly change its shape and reposition its contents.... EXCEPT: something odd happens to my rendering... they sort of get squished, and my rounded corners are now elliptical/squished (even though the rendering code always makes circles) like the UIView applies a transform after the drawRect, but does;t re-render.
This is a very surprising effect, can someone give me a hint to what may be going on? I want the rendering to be consistent and sensitive to the current rectangle.
EDIT: Added pictures. The UIView onDraw renders framing and headers, and there are two UITableViews as children. It starts up in portrait mode (figure 1) and looks fine. When the parent view rotates I initiate an animation that changes the sizing of the subview to be suitable to landscape. The sub UITableViews resize fine, but the rendering is now squished (Figure 2).
You need to set the contentMode of your UIView to Redraw
I have a UIView animation that does a vertical flip animation transition from one view to another. The problem is that the view has some overflowed content (achieved by setting clipsToBounds to NO on the view), and during the animation, the overflowed content gets clipped.
Is there any way to prevent CoreAnimation from clipping the views?
Screenshots
Normal view (notice the paperclip and overhanging rope along the top edge of the map):
Animation in flight: (paperclip and rope are clipped)
I'd recommend placing all the views which rotate inside of a transparent view (kind of placeholder for "map" and "clip"), and applying animation to it rather than to your map view.
Try to set placeholder view's size the way its subviews won't overflow, so you can not worry about hacking clipsToBounds.
have you tried: myView.layer.masksToBounds = NO; ?
I have applied a CABasicAnimation to a layer. The animation modifies the "position.y" layer property to create a gentle bouncing effect; it is set to autoreverse and repeat.
I use the From and To values to position the animation in the bottom right quadrant of the screen. It works quite nicely until I change the orientation of the device. The problem is the animation is positioned relative to the top of the screen. So when the orientation changes it is no longer positioned in the correct place.
The autoresizingMask for the View itself is correctly set in interface builder, but the animation doesn't seem to take any notice of that. I guess because the animation is assigning an absolute value to the layers position.
I'm a bit stumped, thanks in advance.
Can you place your animation in a seperate view so it is self contained and then adjust that view with the rotation?