Am applying a scale transform to UIView (CGAffineTransformMakeScale) which contains UILabel as subview, as I apply transform, the label text gets stretched/compressed as shown in attachment, How can I make the UILabel to render the text correctly even after applying transform.
Apply the transform on the UIView and then add the UILabel as subview. The way you are doing will always transform the UIView and all his subviews. You can also change the UIView frame instead of applying a transform.
Related
I have a UIview with some subviews in it! When I transform that view (scale, rotate.. use CATransform3D). These subviews grow bigger or smaller but the subviews do not change the frame. How can I detect the real frame of them? Thanks!
viewTransfromContainer?.layer.transform = CATransform3DScale((viewTransfromContainer?.layer.transform)!, pinchGes.scale, pinchGes.scale, pinchGes.scale)
I used convert(<#T##rect: CGRect##CGRect#>, to: <#T##UIView?#>) It's work fine with scale But Not return true value when rotate.
image bellow
I want to achieve label/Button embededd in UIImageView in iOS Swift like shown in image.Has anyone done that?
You just need to play with UIView, UILabel And UIImageView.
You view hierarchy will be like below...
- UIView (mainView)
- UIImageView (imageView)
- UILabel
You need to make mainView.clipsToBounds = true so that after giving corner radius to it, it's subview will not go beyond its superview's bounds.
For imageView, you can set its content mode to aspect fill/ aspect fit as per your requirement.
Have a square UIView with clipsToBounds property set to YES which contains UIImageView and UILabel. The image view should cover all the view frame. The label should be positioned at the bottom of the view over the image view. Then just set appropriate corner radius (half of the view's height) for the view's layer and set its masksToBounds property to YES. That's it
In my app, I need to add subview in another view but my issue is that height and width of parentView is 50*50 and height of subview is 150*150 so how can I add this? because when I add this view, rest portion of subview is getting cropped.
The edges are bounded in the smaller UIView. Because the UIView is smaller it is going to crop out the larger subview. if you still want the super view to be 50x50 and don't want the larger subview cropped out then turn off setClipsToBound property of the UIView:
Swift: view.setClipsToBound = false
Objective-C: [view setClipsToBound:NO];
Another solution is just to make the subview smaller or make the superview containing the large subview larger.
guys... I have a button and a vertical stackView with 2 labels inside it. When I tap the button I want to decrease/increase the font size smoothly using animations.
The following code do the animation (within an animation block), but the stackView doesn't resize it self:
self.trackingStatus.transform = CGAffineTransformScale(self.trackingStatus.transform, 0.5, 0.5);
When I use the following code, the stackView does resize, but I don't think you can animate that property:
self.trackingStatus.font = self.trackingStatus.font.fontWithSize(11.0)
Besides the problem with stackView the CGAffineTransformScale makes the text distorted. Could you help me with those two problems?
Thanks a lot!
I have a UIScrollView displayed in fullscreen holding a UIImageView that fills the contentView of the scrollView. I added a method to register the contentOffset and the contentSize of the scrollview at a specific pan and zoom.
I'm trying to convert those coordinates to a CALayer that I can animate using the position and bounds in order to animate a pan and zoom to the desired point.
How to convert the contentOffset and contentSize of a UIScrollView to a CALayer bounds and position properties. The CALayer is a screen sized CALayer and is add to another screen sized CALayer.
Looks like I just had to ask the question to finally answer my own problem!
set the anchorPoint of the CALayer to CGPointZero
then set the bounds size to the contentSize
set the position to the negative contentOffset {-contentOffset.x,-contentOffset.y}
Finally.