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.
Related
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?
I'm trying to use a pinch gesture to scale a collection view only in the y direction. I'm setting the scale correctly (sufficiently), but having trouble keeping the pinched area of the collection view centered.
I've seen many examples of adjusting the translation to keep the pinched content centered, but not to keep a collection view/scroll view content offset centered. Is there something I'm missing here?
I have a sample project which demonstrates it at https://github.com/nickbolton/ScaledCollectionView.
Can anyone offer any suggestions/recommendations/approaches? I'm just not sure where to go with this.
Thanks!
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.
I know there is many topics for this subject but I didn't found a good solution for my problem.
I have a UIScrollView with an image and other components added as subviews.
I just want to know the good way to resize the components into in real time when I zoom.
- (void)scrollViewDidZoom:(UIScrollView *)scrollView {
// Resizing image and other components
}
EDIT : I would like the impression that the components inside the scroll view keep the same size when I zoom. I don't want to they become bigger or smaller during zooming.
EDIT : Here is the hierarchy of my UIViewController
View
ScrollView
Main view
Image view
Drawing view (UIView with components like UILabel, other UIViews, etc...)
Thanks a lot !
I would leave the scale of UIScrollView as it is and reach the goal with the help of subview (adjusting its size, not scrollView's), where I would place all the subviews and the images you work with.
So it would be something like:
yourView.transform = CATransform3DMakeScale(newScale, newScale, 1.0);
where yourView is the main (only) subview of scrollView. Then I would recalculate the size of the yourView with new scale and set it to scrollView's contentSize parameter so that you could actually scroll the enlarged content, not only see it truncated.
The only thing is that in this case you should use the callback other than scrollViewDidZoom: I guess.
P.S. Changing UIView's transform parameter you don't need to bother about subviews' scale: CoreAnimation does everything for you.
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?