UI基本控件(08-03)

//
//  AppDelegate.m
//  UI01_基本控件
//
//  Created by lanou3g on 17/8/3.
//  Copyright © 2017年 lanou3g. All rights reserved.
//

#import "AppDelegate.h"
#import "RootViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    RootViewController *rootViewController = [[RootViewController alloc] init];
    self.window.rootViewController = rootViewController;
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

//
//  RootViewController.m
//  UI01_基本控件
//
//  Created by lanou3g on 17/8/3.
//  Copyright © 2017年 lanou3g. All rights reserved.
//

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40, 60, 100, 40)];
    label.backgroundColor = [UIColor orangeColor];
    label.text = @"哈哈";
    label.textColor = [UIColor whiteColor];
    //文本水平方向的对齐方式
    label.textAlignment = NSTextAlignmentCenter;
    //设置字体
//    label.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    label.font = [UIFont systemFontOfSize:25];
    //行数
    label.numberOfLines = 2;
    //换行形式
    label.lineBreakMode = NSLineBreakByCharWrapping;
    //阴影颜色
    label.shadowColor = [UIColor yellowColor];
    //阴影偏移大小
    label.shadowOffset = CGSizeMake(2, 1);
    [self.view addSubview:label];
    
    
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(40, 120, 200, 40)];
    //占位文本
    textField.placeholder = @"请输入:";
    //边框风格
    textField.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:textField];
    textField.text = @"sniper";
    //当编辑时是否清空内容
    textField.clearsOnBeginEditing = YES;
    //密文
    textField.secureTextEntry = YES;
    //键盘类型
    textField.keyboardType = UIKeyboardTypeNumberPad;
    
    
    int x=50;
    int y=50;
    int width=50;
    int height=50;
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            UIView *tempView=[[UIView alloc]initWithFrame:CGRectMake(x+j*55, y+i*55, width, height)];
            // tempView.backgroundColor=[UIColor redColor];
            tempView.backgroundColor=[UIColor colorWithRed:(arc4random()%256/256.0) green:(arc4random()%128/256.0) blue:(arc4random()%128/256.0) alpha:2.0];
            [self.view addSubview:tempView];
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

你可能感兴趣的:(UI基本控件(08-03))