ios - Changing the layout of an AlertController -


i have used following code try , change layout of uialertcontroller using nib dialog shows , looks same each time regardless of nib specified, looks translucent grey box, @ bottom of screen.

class alertdialogviewcontroller: uiviewcontroller {  var message: string = ""  override init() {     super.init(nibname: "signupviewcontroller", bundle: nil)     //below 2 lines important custom transitions.     transitioningdelegate = self     modalpresentationstyle = .custom }  required init(coder adecoder: nscoder) {     super.init(coder: adecoder) }  //other code dialog controller // . // . // . }  extension alertdialogviewcontroller : uiviewcontrolleranimatedtransitioning {  func transitionduration(transitioncontext: uiviewcontrollercontexttransitioning) -> nstimeinterval {     return 0.5 //add own duration here }  func animatetransition(transitioncontext: uiviewcontrollercontexttransitioning) { //add presentation , dismiss animation transition here. } }  extension alertdialogviewcontroller : uiviewcontrollertransitioningdelegate {  func animationcontrollerforpresentedcontroller(presented: uiviewcontroller, presentingcontroller presenting: uiviewcontroller, sourcecontroller source: uiviewcontroller) -> uiviewcontrolleranimatedtransitioning? {     return self }  func animationcontrollerfordismissedcontroller(dismissed: uiviewcontroller) -> uiviewcontrolleranimatedtransitioning? {     return self }  }  extension uiviewcontroller {  func showaleartwithmessage(message: string) {     var ad = alertdialogviewcontroller()     ad.message = message     presentviewcontroller(ad, animated: true, completion: nil) } } 

you can't

the uialertcontroller class intended used as-is , not support subclassing. view hierarchy class private , must not modified.

edit: relevant code said in comment added

imagine want dialog box uilable , 2 uibuttons instance

class customview : uiview {    var commentlabel: uilable!    var okaybutton: uibutton!    var cancelbutton: uibutton!     init(frame: cgrect) {      super.init(frame: frame)        commentlabel = uilabel()      okaybutton = uibutton.buttonwithtype(.custom)      cancelbutton = uibutton.buttonwithtype(.custom)       // todo: configuration such target, action, titlelable, etc. left user        [commentlabel, okaybutton, cancelbutton].map { self.addsubview($0) }    }     @ibaction func okaybuttonaction(sender: anyobject) {       // todo: complete implementation     }     @ibaction func okaybuttonaction(sender: anyobject) {       // todo: complete implementation    }  }   class customalertdialogviewcongroller : uiviewcontroller {   override func loadview() {     self.view = customview(frame: cgrect(x: 0, y: 0, width: 200, height: 100))   } }  // in view controller want present alert dialog. let's call viewcontroller  let customalertdialogviewcontroller = customalertdialogviewcongroller() customalertdialogviewcontroller.modalpresentationstyle = .uimodalpresentationformsheet customalertdialogviewcontroller.modaltransitionstyle = .coververtical  viewcontroller.presentviewcontroller(customalertdialogviewcontroller, animated: true, completion: nil) 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -