p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff; min-height: 28.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #00afca }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #4dbf56 }
span.s1 { color: #c2349b }
span.s2 { }
span.s3 { color: #00afca }
span.s4 { color: #ffffff }
span.s5 { color: #93c96a }
span.s6 { color: #e44347 }
span.s7 { font: 24.0px "PingFang SC"; color: #e44347 }
span.s8 { color: #8b84cf }
import UIKit
class ViewController: UIViewController {
var button : UIButton!
var array = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.white
array = ["风格一","风格二","风格三"]
creatBtn()
}
func creatBtn(){
for i in 0..<3 {
button = UIButton(frame: CGRect(x: 30, y: 50 + i * 60, width: 315, height: 30))
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: "选择照片", preferredStyle: .actionSheet)
let photo = UIAlertAction(title: "相册", style: .default, handler: { action in
})
let camera = UIAlertAction(title: "相机", style: .default, handler: { action in
})
let cancel = UIAlertAction(title: "取消", 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: "提示", message: "验证码错误", preferredStyle: .alert)
let ok = UIAlertAction(title: "确定", style: .default, handler: { action in
})
let cancel = UIAlertAction(title: "取消", style: .default, handler: { action in
})
action.addAction(ok)
action.addAction(cancel)
self.present(action, animated: true, completion: nil)
}else {
print("我是第三种风格")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}