ios開(kāi)發(fā)--常用基本控件(截取登陸部分)

一:UITextField

_messageText=[[UITextField alloc]init];

_messageText.borderStyle=UITextBorderStyleRoundedRect;

_messageText.placeholder=@"SSSS";

_messageText.font=[UIFont fontWithName:@"Arial" size:15.0f];

_messageImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"account-"]];

_messageText.leftView=_messageImage;

_messageText.leftViewMode=UITextFieldViewModeAlways;

_messageText.keyboardType=UIKeyboardTypeDefault;

//密碼隱藏

_messageText.secureTextEntry = YES;

_messageText.delegate=self;

[self.view addSubview:_messageText];

//點(diǎn)擊空白區(qū)域回收鍵盤(pán),并且view回到初始狀態(tài)

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{

[_messageText resignFirstResponder];

}

//點(diǎn)擊鍵盤(pán)Return建回收鍵盤(pán),并且view回到初始狀態(tài)

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

[_messageText resignFirstResponder];

return YES;

}

二:UIButton

_loginButton=[[UIButton alloc]init];

_loginButton.backgroundColor=[UIColor colorWithRed:52/255.f green:138/255.f blue:76/255.f alpha:1.00];

[_loginButton setTitle:@"登錄" forState:UIControlStateNormal];

[_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

[_loginButton addTarget:self action:@selector(loginBut:) forControlEvents:UIControlEventTouchUpInside];

//button點(diǎn)擊事件,包括判斷用戶,密碼的輸入狀態(tài),以及彈窗

-(void)loginBut:(UIButton *)button{

if ([self.messageText.text compare:@""]==NSOrderedSame ||[self.passText.text compare:@""]==NSOrderedSame )

{

UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:@"用戶、密碼不能為空"? delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];

[alertV show];

}else if (self.messageText.text.length <4 || self.passText.text.length<6)

{

UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"提示" message:@"用戶名密碼不匹配)"? delegate:self cancelButtonTitle:@"確定" otherButtonTitles:nil, nil];

[alertV show];

}

}




友情植入,喜歡的可以加個(gè)微博

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • iOS開(kāi)發(fā)系列--網(wǎng)絡(luò)開(kāi)發(fā) 概覽 大部分應(yīng)用程序都或多或少會(huì)牽扯到網(wǎng)絡(luò)開(kāi)發(fā),例如說(shuō)新浪微博、微信等,這些應(yīng)用本身可...
    lichengjin閱讀 4,028評(píng)論 2 7
  • //設(shè)置尺寸為屏幕尺寸的時(shí)候self.window = [[UIWindow alloc] initWithFra...
    LuckTime閱讀 965評(píng)論 0 0
  • 概述在iOS開(kāi)發(fā)中UITableView可以說(shuō)是使用最廣泛的控件,我們平時(shí)使用的軟件中到處都可以看到它的影子,類似...
    liudhkk閱讀 9,289評(píng)論 3 38
  • 概述 在多數(shù)移動(dòng)應(yīng)用中任何時(shí)候都只能有一個(gè)應(yīng)用程序處于活躍狀態(tài),如果其他應(yīng)用此刻發(fā)生了一些用戶感興趣的那么通過(guò)通知...
    莫離_焱閱讀 6,708評(píng)論 1 8
  • 看過(guò)《解憂雜貨店》就有一種想法,很多時(shí)候我們糾結(jié)的事在發(fā)生后會(huì)覺(jué)得不值一提,很多時(shí)候我們糾結(jié)的事就是需要有人幫忙指...
    拾香流年閱讀 187評(píng)論 0 0

友情鏈接更多精彩內(nèi)容