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];
    //文本水平方向的對(duì)齊方式
    label.textAlignment = NSTextAlignmentCenter;
    //設(shè)置字體
//    label.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    label.font = [UIFont systemFontOfSize:25];
    //行數(shù)
    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 = @"請(qǐng)輸入:";
    //邊框風(fēng)格
    textField.borderStyle = UITextBorderStyleRoundedRect;
    [self.view addSubview:textField];
    textField.text = @"sniper";
    //當(dāng)編輯時(shí)是否清空內(nèi)容
    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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末三椿,一起剝皮案震驚了整個(gè)濱河市浸策,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌群凶,老刑警劉巖,帶你破解...
    沈念sama閱讀 212,454評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件猜绣,死亡現(xiàn)場離奇詭異课舍,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)收夸,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,553評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門坑匠,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人卧惜,你說我怎么就攤上這事厘灼。” “怎么了咽瓷?”我有些...
    開封第一講書人閱讀 157,921評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵设凹,是天一觀的道長。 經(jīng)常有香客問我茅姜,道長闪朱,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,648評(píng)論 1 284
  • 正文 為了忘掉前任钻洒,我火速辦了婚禮奋姿,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘素标。我一直安慰自己称诗,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,770評(píng)論 6 386
  • 文/花漫 我一把揭開白布头遭。 她就那樣靜靜地躺著寓免,像睡著了一般。 火紅的嫁衣襯著肌膚如雪计维。 梳的紋絲不亂的頭發(fā)上袜香,一...
    開封第一講書人閱讀 49,950評(píng)論 1 291
  • 那天,我揣著相機(jī)與錄音鲫惶,去河邊找鬼蜈首。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的疾就。 我是一名探鬼主播澜术,決...
    沈念sama閱讀 39,090評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼猬腰!你這毒婦竟也來了鸟废?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,817評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤姑荷,失蹤者是張志新(化名)和其女友劉穎盒延,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體鼠冕,經(jīng)...
    沈念sama閱讀 44,275評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡添寺,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,592評(píng)論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了懈费。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片计露。...
    茶點(diǎn)故事閱讀 38,724評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖憎乙,靈堂內(nèi)的尸體忽然破棺而出票罐,到底是詐尸還是另有隱情,我是刑警寧澤泞边,帶...
    沈念sama閱讀 34,409評(píng)論 4 333
  • 正文 年R本政府宣布该押,位于F島的核電站,受9級(jí)特大地震影響阵谚,放射性物質(zhì)發(fā)生泄漏蚕礼。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,052評(píng)論 3 316
  • 文/蒙蒙 一梢什、第九天 我趴在偏房一處隱蔽的房頂上張望奠蹬。 院中可真熱鬧,春花似錦嗡午、人聲如沸囤躁。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,815評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至金度,卻和暖如春应媚,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背猜极。 一陣腳步聲響...
    開封第一講書人閱讀 32,043評(píng)論 1 266
  • 我被黑心中介騙來泰國打工中姜, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,503評(píng)論 2 361
  • 正文 我出身青樓丢胚,卻偏偏與公主長得像翩瓜,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子携龟,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,627評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容