2014-04-02 46 views
1

這裏是MyView的的iOS - 查看旋轉和調整

Here is myView

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

現在,當我旋轉視圖

enter image description here

並再次做到這一點

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

這裏發生了什麼?

看起來像寬度拉伸。

無論如何要修復它或有其他方式來旋轉和調整大小?

回答

1

您應該使用boundscenter特性來調整,把你的觀點,框架不應該被使用,如果變換屬性不恆等變換

(見本UIView documentation for frame警告)

frame.size是不等於bounds.size當您的視圖旋轉時,如果您希望視圖的寬度爲300,則應設置邊界

+0

謝謝您的回答!是工作! – user3121366