~~~
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
UITextField *textFiled;
- (void)viewDidLoad {
[super viewDidLoad];
[self addTextField];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) addTextField
{
UILabel *prefixLabel = [[UILabel alloc]initWithFrame:CGRectZero];
prefixLabel.text=@"輸入用戶名:";
[prefixLabel setFont:[UIFont boldSystemFontOfSize:14]];
[prefixLabel sizeToFit];
textFiled = [[UITextField alloc] initWithFrame:CGRectMake(20, 50, 280, 30)];
textFiled.borderStyle = UITextBorderStyleRoundedRect;
textFiled.contentVerticalAlignment=UIControlContentVerticalAlignmentCenter;
[textFiled setFont:[UIFont boldSystemFontOfSize:12]];
textFiled.placeholder = @"Simple Text filed";
[textFiled setTextColor:[UIColor blueColor]];
textFiled.leftView = prefixLabel;
textFiled.leftViewMode = UITextFieldViewModeAlways;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setTitle:@"提交" forState:UIControlStateNormal];
[btn sizeToFit];
textFiled.rightView=btn;
textFiled.rightViewMode = UITextFieldViewModeAlways;
[btn addTarget:self action:@selector(onClick) forControlEvents:UIControlEventTouchUpInside] ;
[self.view addSubview:textFiled];
}
-(void)onClick
{
NSLog(@"獲取輸入框值:%@",textFiled.text);
}
@end
~~~
- 各種語言一起擼
- 前言
- 第一章 各種語言類講解對比
- 1.1 基于類的面向對象語言
- 第二章 各種語言面向對象編程
- 2.1 Javascript面向對象編程
- 2.1.1 JS類實現
- 2.1.2 JS類繼承
- 2.2 Object-C面向對象編程
- 2.3 Android面向對象編程
- 2.4 PHP面向對象編程
- 第三章 JS+OC+ADT語言對比
- 3.1 視圖
- 3.1.1 JavaSript創建視圖
- 3.1.2 Object-c創建視圖
- 3.1.2.1 xib視圖視圖創建
- 3.1.3 Andriod創建視圖
- 3.1.3.1 xml視圖創建
- 3.2 事件
- 3.2.1 JavaSript事件綁定
- 3.2.2 Object-c事件代理
- 3.2.2.1 事件代理
- 3.2.3 Andriod事件監聽
- 第四章 PHP服務端語言