//mark: 文字輸入框
func _inittextfield() {
//如果需要在模擬器中呼叫電腦的鍵盤 快捷鍵:command + shift + k
let textfield = uitextfield(frame: cgrect(x: 100, y: 100, width: 200, height: 30))
textfield.backgroundcolor = uicolor.redcolor()
textfield.tag = 100
textfield.delegate = self
self.view.addsubview(textfield)
//設定輸入框的邊框樣式 預設無邊框
textfield.borderstyle = uitextborderstyle.roundedrect
//設定輸入文字的字型
textfield.font = uifont.boldsystemfontofsize(10)
//設定文字的顏色
textfield.textcolor = uicolor.greencolor()
//設定或獲取輸入框中的內容
// textfield.text = "hehe"
//設定對齊方式
textfield.textalignment = nstextalignment.center
//設定首字母是否自動大寫
textfield.autocapitalizationtype = uitextautocapitalizationtype.words
//設定自動單詞提示
textfield.autocorrectiontype = uitextautocorrectiontype.yes
//輸入框為空時的提示文字
textfield.placeholder = "請輸入登陸郵箱"
//修改鍵盤上的return按鈕上的標題
textfield.returnkeytype = uireturnkeytype.next
//輸入框是否安全輸入
textfield.securetextentry = true
//數字鍵盤
// textfield.keyboardtype = uikeyboardtype.numberpad
//開啟清楚按鈕
textfield.clearbuttonmode = uitextfieldviewmode.whileediting
// //成為第一響應者,彈出鍵盤
textfield.becomefirstresponder()
// //失去第一響應者,收起鍵盤
// textfield.resignfirstresponder()
let btn = uibutton(type: uibuttontype.contactadd)
btn.frame = cgrect(x: 0, y: 100, width: 50, height: 50)
btn.addtarget(self, action: "btnclick:", forcontrolevents: uicontrolevents.touchupinside)
self.view.addsubview(btn)
func btnclick(btn: uibutton) {
//失去第一響應者
let textfield = self.view.viewwithtag(100) as! uitextfield
textfield.resignfirstresponder()
//mark: uitextfielddelegate
//將要開始編輯
func textfieldshouldbeginediting(textfield: uitextfield) -> bool {
print("將要開始編輯")
//返回true表示繼續編輯,返回false是阻止編輯
return true
//開始編輯
func textfielddidbeginediting(textfield: uitextfield) {
print("開始編輯")
//結束編輯時呼叫的協議方法
func textfielddidendediting(textfield: uitextfield) {
print("已經結束")
//輸入框的內容被修改時呼叫的協議方法
func textfield(textfield: uitextfield, shouldchangecharactersinrange range: nsrange, replacementstring string: string) -> bool {
print("range is \(range), string is \(string)")
return true
wxVectorProperty 屬性的設定
用wx中屬性網格屬性設定時遇到了些麻煩。為了設定編輯器中模型的3d座標,在屬性網格中加了3d座標屬性。但是在設定wxvectorproperty,不知道如何設定。後來在wxpropertygridproperties檔案中找到了這個巨集wx pg declare variant data wxvec...
CSS的各種屬性
css的各種屬性 css的單位 a.絕對單位 1in 2.54cm 25.4mm 72pt 6pc pt是點或者磅,pc是派卡 b.相對單位 px,em 印刷單位相當於12個點 相對周圍的文字 字型設定 p 文字設定 p 背景設定 body 列表設定 ul li 盒子模型 border margin...
UILabel的各種屬性
uilable是iphone介面最基本的控制項,主要用來顯示文字資訊。常用屬性和方法有 1 建立 cgrect rect cgrectmake 100,200,50,50 uilabel label uilabel alloc initwithframe rect 2 text 設定和讀取文字內容,...