Import UIKit
Class Viewcontroller: uiviewcontroller {
var button: UIButton!
var array = nsmutablearray()
override func viewdidload () {
Super. Viewdidload()
self. View. BackgroundColor = uicolor. White
array = [" style one "," style two "," style three "]
creatbtn()
}
func creatbtn () {
for i in 0.. <3 {
button = UIButton(frame: cgrect(x: y: + i * , Width: 315, Height: ))
button. BackgroundColor = uicolor. Gray
button. Tag = i
button. Settitle(array[i] as? String, for:. Normal)
button. AddTarget(self, action: #selector(remind(btn:)), for:. Touchupinside)
self. View. Addsubview(button)
}
}
func remind (btn: UIButton) {
if btn. Tag = = 0 {
let action = uialertcontroller(title: Nil, message: " Select Photo ", Preferredstyle:. actionsheet)
let photo = uialertaction(title: " album ", Style:. ) Default, Handler: {action in
})
let camera = uialertaction(title: " camera ", Style:. ) Default, Handler: {action in
})
let cancel = uialertaction(title: " cancel ", Style:. ) Default, Handler: {action in
})
Action. addaction(photo)
Action. addaction(camera)
Action. addaction(cancel)
self. Present(action, animated: True, completion: nil)
}Else if btn. Tag = = 1{
let action = uialertcontroller(title: " hint ", Message: " captcha error " , Preferredstyle:. alert)
let ok = uialertaction(title: " OK ", Style:. ) Default, Handler: {action in
})
let cancel = uialertaction(title: " cancel ", Style:. ) Default, Handler: {action in
})
Action. addaction(OK)
Action. addaction(cancel)
self. Present(action, animated: True, completion: nil)
}Else {
Print(" I am the third style ")
}
}
override func didreceivememorywarning () {
Super. Didreceivememorywarning()
//Dispose of any resources, can be recreated.
}
}
Swift_ Reminder Box