2016-08-23 16 views
7

UIAlertController çalışıyor, ancak alert.view'u 90 derece sola döndürmek istiyorum.UIAlertController'ı Swift uygulamasında döndürme

Bunu nasıl yapabilirim? Ben eklemek çalıştı

let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) 
alert.addAction(UIAlertAction(title: "Okay", style: .Default){(action)->() in }) 
presentViewController(alert, animated: true) {} 

:

alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) 

ama çalışmıyor Kodum burada altındadır.

Teşekkür ederiz!

let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) 
alert.addAction(UIAlertAction(title: "Okay", style: .Default){(action)->() in }) 

self.presentViewController(alert, animated: true, completion: {() -> Void in 
     alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) 

}) 

swift3 Sen bunu başarabilirsiniz

let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .alert) 
    alert.addAction(UIAlertAction(title: "Okay", style: .default){(action)->() in }) 

    self.present(alert, animated: true, completion: {() -> Void in 
     alert.view.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi/2)) 

    }) 

:

enter image description here

Güncelleme cevapBu kod ile

cevap

8
self.presentViewController(alert, animated: true, completion: {() -> Void in 
     // alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) 

     UIView.animateWithDuration(1.0, delay: 0, options: .CurveLinear, animations: {() -> Void in 
      alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) 
     }) { (finished) -> Void in 
      // do something if you need 
     } 

    }) 
+0

Teşekkür ederim ama çalıştı! 1 saniyelik 90 dereceden sola dönünce ilk önce normal görünmeyi gösteren uyarı olduğunda 1 sorun yaşayın. Bunu nasıl çözebiliriz? – SwiftDeveloper

+0

@SwiftDeveloper - tamam kardeşim aldım, biraz zaman ver, küçük bir işim var, tamamladım ve işine başladım –

+0

Teşekkür ederim kardeşim çözmemiz gerekiyor sanırım birçok insana yardım edecek! – SwiftDeveloper