一、建立乙個button
var btnclik:uibutton = uibutton(type: .custom)
override func viewdidload() {
super.viewdidload()
self.view.backgroundcolor = uicolor.redcolor()
btnclik.frame = cgrectmake(0, 0, 60, 54)
btnclik.backgroundcolor = uicolor.bluecolor()
btnclik.center = cgpointmake(160, 200)
btnclik.settitle("戳我啊", forstate:.normal)
btnclik.addtarget(self, action:"showalertcontroller", forcontrolevents: .touchupinside)
view.addsubview(btnclik)
button分別呼叫以下兩個方法
1.原始的alertview
func showalert(){
let msgtitle:string = "歡迎光臨"
let message:string = "不要歡飲光臨"
let alert:uialertview = uialertview()
alert.title = msgtitle;
alert.message = message
alert.addbuttonwithtitle("現在去**")
alert.show()
2.ios系統9.0以後的alertview
func showalertcontroller(){
let title = "歡迎光臨"
let message = "不要歡迎光臨"
let btnleft = "no...."
let btnright = "現在帶我走"
let alertcontroller = uialertcontroller(title: title, message: message, preferredstyle: .alert)
let actionleft = uialertaction(title:btnleft, style: .cancel) { action in
nslog("not so interested in the site.")
let actionright = uialertaction(title:btnright, style: .default) { action in
nslog("hook, line and sinker!")
alertcontroller.addaction(actionleft)
alertcontroller.addaction(actionright)
presentviewcontroller(alertcontroller, animated: true, completion: nil)
原生js寫倒計時的兩種形式
形式1 10到0遞減 time 10div var time document.getelementbyid time 設定時間 var i 10 開啟計時器,每間隔一秒執行一次函式 var time1 setinterval function time.innerhtml i 1000 scrip...
C C 的兩種多型形式
1 2 test.cpp4 5 created by mac on 15 8 11.6 7 8 include9 include10 using namespace std 11class person 基類person12 25person person 26 person person stri...
include的兩種指令形式
在程式設計過程中不在意的細節 搬運於c程式設計 include include stdio.h include使用尖括號的形式時,編譯系統從存放c編譯系統的子目錄中去找所要包含的檔案如 stdio.h 這稱為 標準方式 若使用 include指令是為了使用系統庫函式,因而要包含系統提供的相應標頭檔案...