3
嘗試
此代碼CALayer sublayerTransform(CATransform3D) - 如何移動「相機」?
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = -1.0/1000.0;
perspectiveTransform = CATransform3DRotate(perspectiveTransform, angle/2.0, 0.0, 1.0, 0.0);
self.sublayerTransform = perspectiveTransform;
給出了這樣的結果
紅色幀是該層的背景色
嘗試乙
這段代碼
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = -1.0/1000.0;
// following line is added
perspectiveTransform = CATransform3DTranslate(perspectiveTransform, -width/2.0, 0, 0);
perspectiveTransform = CATransform3DRotate(perspectiveTransform, angle/2.0, 0.0, 1.0, 0.0);
self.sublayerTransform = perspectiveTransform;
給出了這樣的結果
紅框是層
那麼,什麼是錯的背景顏色?
在從「嘗試」是從左側中心觀察,因此,摺疊從錯誤的角度觀察所呈現的示例(左摺疊變得比右邊倍稍薄)
通過平移它在x軸,就像在「嘗試B」中一樣,我能夠正確地渲染它,但是接着出現另一個錯誤:內容現在超出界限(紅色矩形是界限)。
我怎樣才能讓相機從中間?
LoL如果您發佈其他更改,將有助於其他人遇到同樣的問題:) –
好主意。我沒有透露很多代碼,所以我認爲它並不重要。但基本上我只是不得不翻譯其他意見相應(不通過sublayerTransform) – hfossli
感謝您提供一些解決方案的細節可能這將幫助一個人,也提高你的聲譽:) –