ios 学习第五天(一)对页面进行修改。昨天,我们创建了一个 app,里面有一个 Hello IOS 的闪屏,一个空白的页面,下面我们对它进行修改,让背景颜色变成其他颜色。
在这里,颜色分量的值不是 0-255,是 0-1,颜色用 rgba 合成。可自由调整 r=1,g=0,b=0,a=1 代表不透明红色;r=1,g=0,b=0,a=0.5 代表半透明红色; r=1,g=1,b=1,a=1 代表不透明白色。UIViewController 代表一个个页面。
- //// ViewController.m// HelloIOS//// Created by Moluth on 17/4/10.// Copyright (c) 2017年 Moluth. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor=[[UIColor alloc] initWithRed:0.3f green:0.35f blue:0.85f alpha:1.0f]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
在文件 AppDelegate.m 中修改第一个运行的函数中加入如下代码
- - (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]; self.window.rootViewController=[[ViewController alloc] init]; NSLog(@"application"); return YES;}
UIWindow 是一个窗口,里面用来放 UIViewController,UIViewController 中放 UIView。UIView 是接下来学习的重点,UIView 的子类包含按钮,文本等控件。
就爱阅读 www.92to.com 网友整理上传, 为您提供最全的知识大全, 期待您的分享,转载请注明出处。
来源: http://www.92to.com/bangong/2017/04-11/20300390.html