登錄頁面

登錄頁面除了簡單布局控件之外,所用的方法技巧:
1.控件透明度設置
我們在設置控件的透明度時,用alpha往往會使我們不希望透明的部分也透明了,例如:
我們在設置textField的透明度時,我們輸入的字體內容也會跟著變透明,然而這并不是我們想要的。解決方法:
UIColor *color = [UIColor colorWithRed:135/255.0 green:206/255.0 blue:250/255.0 alpha:1];
_accountText.backgroundColor = [color colorWithAlphaComponent:0.7];
通過這個方法可以使控件本身透明,而字體不透明。
2.控件圓角
_accountText.layer.cornerRadius = 5;
_accountText.layer.masksToBounds = YES;
3.彈出輸入框
UIBarButtonItem *leftBtn = [[UIBarButtonItem alloc]initWithTitle:@"我是管理員" style:UIBarButtonItemStylePlain target:self action:@selector(manageLogin)];
self.navigationItem.leftBarButtonItem = leftBtn;
-(void)manageLogin{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"管理員登錄" preferredStyle:UIAlertControllerStyleAlert];
//增加確定按鈕;
[alertController addAction:[UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//獲取第1個輸入框;
UITextField *userNameTextField = alertController.textFields.firstObject;
//獲取第2個輸入框;
UITextField *passwordTextField = alertController.textFields.lastObject;

     NSLog(@"用戶名 = %@,密碼 = %@",userNameTextField.text,passwordTextField.text);
    
}]];

//增加取消按鈕;
[alertController addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]];

//定義第一個輸入框;
[alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
    textField.placeholder = @"輸入管理員";
}];
//定義第二個輸入框;
    [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
        textField.placeholder = @"請輸入密碼";
        textField.secureTextEntry = YES;
    }];

[self presentViewController:alertController animated:true completion:nil];

}

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容