2015-04-08 31 views
0

基本上我想構建像iOS7 Safari瀏覽器標籤切換器中的滾動視圖。我使用CATransform3D來獲得傾斜的感覺。但是,當我使用變換時,圖層不會以正確的順序顯示(它們在變換之前是按照正確的順序排列的,看起來像是一個完全顛倒的順序。後面的圖層跳轉到前面)。我該如何解決這個棘手的問題? 順便說一句,在我的情況superView.bringSubViewToFront不起作用。CATransform3D打破圖層順序?

我的代碼:

 //Create imageView 
    ... 
    scroller.addSubview(imageView) 
    let layer = imageView.layer 
    //Set shadow 
    layer.shadowOpacity = 0.2 
    layer.shadowRadius = 2 
    layer.shadowOffset = CGSizeMake(6, -10) 

     //Transform, if without following code the layer order is correct 
    var transform = CATransform3DIdentity 
    transform.m34 = 0.0009 
    let radiants = 0.11*M_PI 
    transform = CATransform3DRotate(transform, CGFloat(radiants), 1.0, 0.0, 0.0) 
    scroller.bringSubviewToFront(imageView)//It doesn't work. 

回答

1

我剛發現,如果你在CATransform3DTranslate設定z軸,以1.0的層中其它層的前面成爲,所以只是使它0