Swift_ Reminder Box

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.