1  1 1.AppDelegate.m
 2  2 
 3  3 #import “OneViewController.h”
 4  4 //一打开就运行的
 5  5 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 6  6 {
 7  7     self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
 8  8     OneViewController *oneController = [[OneViewController alloc] init];
 9  9     [self.window setRootViewController:oneController];
10 10     [self.window makeKeyAndVisible];
11 11     return YES;
12 12 }
13 13 
14 14 2.OneViewController.m
15 15 
16 16 #import “TwoViewController.h”
17 17 -(void)viewDidLoad
18 18 {
19 19 [super viewDidLoad];
20 20 self.view.backgroundColor = [UIColor orangeColor];
21 21 
22 22 [self OneButton];
23 23 }
24 24 //添加button
25 25 #pragma mark – Button
26 26 -(void)OneButton
27 27 {
28 28     UIButton *myButton = [[UIButton alloc] init];
29 29     myButton.frame = CGRectMake(120,300,90,35);
30 30     myButton.backgroundColor = [UIColor grayColor];
31 31     [myButton setTitle:”确定” forState:UIControlStateNormal];
32 32     [self.view.addSubview:myButton];
33 33 //addSubview: 添加一个视图对接收者的子视图列表。
34 34     [myButton addTarget:self action:@selector(ClickMyButton) forControlEvents:UIControlEventTouchUpInside];
35 35 //addTarget: 将目标对象和动作方法与控制关联。
36 36 }
37 37 //Button点击事件
38 38 #pragma mark - Button
39 39 -(void)ClickButton
40 40 {
41 41     TwoViewController *two = [[TwoViewController alloc] init];
42 42     //跳转到下一页面    
43 43   [self presentViewController:two animated:YES completion:nil];
44 44 }
45 45 //跳转到上一页面
46 46 [self dismissViewControllerAnimated:YES completion:nil];
47 47 
48 48 3.Label
49 49 
50 50 [self label1];
51 51 
52 52 -(void)Label
53 53 {
54 54     UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(1,2,3,4)];
55 55     label1.backgroundColor = [UIColor whiteColor];
56 56     label1.text = @”显示”;
57 57     label1.textColor = [UIColor blackColor];
58 58     [self.view addSubview:label1];
59 59 }
60 60 
61 61 4.TextField
62 62 
63 63 [self _text];
64 64 
65 65 -(void)TextField
66 66 {
67 67     _text = [[UITextField alloc] initWithFrame:CGRectMake(1,2,3,4)];
68 68     _text.borderStyle = UITextBorderStyleRoundedRect;
69 69     _text.backgroundColor = [UIColor whiteColor];
70 70     _text.placeholder = @”请输入密码”;
71 71     _text.textColor = [UIColor blackColor];
72 72     _text.keyboardType = UIKeyboardTypeDefault;
73 73     _text.returnKeyType = UIReturnKeyGo;
74 74     [self.view addSubview:_text];
75 75 }
76  

 

posted on 2016-04-04 13:22  Jackson_Yi  阅读(387)  评论(0)    收藏  举报