user3121366
user3121366

Reputation: 67

iOS - View rotate and resize

Here is myView

Here is myView

When

self.myView.transform = CGAffineTransformMakeRotation(M_PI*0/180);

[self.myView setFrame:CGRectMake:(self.myView.frame.orgin.x,self.myView.frame.orgin.y,300,self.myView.frame.size.height)];

it will be

enter image description here

now when i rotate the view

enter image description here

And do this again

self.myView.transform = CGAffineTransformMakeRotation(M_PI*0/180);

[self.myView setFrame:CGRectMake:(self.myView.frame.orgin.x,self.myView.frame.orgin.y,300,self.myView.frame.size.height)];

enter image description here

What happened here?

seen like the width is stretched.

Its anyway to fix it or have other way to rotate and resize?

Upvotes: 1

Views: 200

Answers (1)

Pieter
Pieter

Reputation: 17715

You should use the bounds and center properties to resize and place your view, frame should not be used if the transform property is not the identity transform

(see warning at the UIView documentation for frame)

frame.size is not equal to bounds.size when your view is rotated, if you want your view to have a width of 300, you should set the bounds

Upvotes: 1

Related Questions