@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
UI 即:用户界面 UIWindow的使用 用法
对UIWindow 进行初始化 IOS 程序的入口
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
(self.window = [[UIWindow alloc] init ];//WithFrame:[UIScreen mainScreen].bounds];//创建window,让其充满屏幕
self.window.frame = [[UIScreen mainScreen]bounds];)(第一种方法)
self.window=[[UIWindow alloc]initWithFrame:[UIScreen mainScreen] .bounds];(第二种方发)
//[self.window makeKeyAndVisible];//让window成为主窗口且可视
self.window.backgroundColor = [UIColor redColor];//设置背景色
self.window.rootViewController = [[ViewController alloc] init];//设置根视图控制器
// Override point for customization after application launch.
return YES;
}
UIView 视图 (进入view 创建UIView)的入口
UIview的方法
- (void)viewDidLoad {
[super viewDidLoad];
UIview *view = [[UIView alloc] init];
view.frame = CGRectMake(10, 20, 100, 100);//相对于父视图的位置,注意坐标和尺寸的合理性,保证坐标加尺寸不会超出父视图范围
view.userInteractionEnabled = YES;//是否允许用户点击(默认YES),如果设置成no,子视图不会覆盖父视图的点击事件
self.view.backgroundColor=[UIColor blackColor];
view.backgroundColor = [UIColor redColor];
[self.view addSubview:view];//将后面的视图添加到前面的视图之上
self.view.userInteractionEnabled = YES;//如果父视图不允许交互,那么子视图的事件也会被屏蔽
view.tag =1;//设置视图的标签
view.alpha = 1;//设置视图的透明度,0~1(从透明到不透明)
self.view.alpha = 1;//如果父视图透明,那么子视图也会看不见
view.hidden = YES;//设置视图是否隐藏(默认NO)
self.view.hidden = YES;//如果父视图被隐藏,那么子视图也会被隐藏
UIView *view3 = [self.view viewWithTag:1];//获取父视图中标签为1的视图
view3.backgroundColor = [UIColor greenColor];
UIView *view5 = [[UIView alloc] initWithFrame:CGRectMake(10, 30, 100, 200)];
view5.backgroundColor = [UIColor blackColor];
[self.view addSubview:view5];
[view5 removeFromSuperview];//将视图移除父视图
UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 200, 300)];
view1.backgroundColor = [UIColor greenColor];
[self.view addSubview:view1];
view1.alpha =1;
[view1 removeFromSuperview];
[self.view insertSubview:view1 atIndex:3];//将子视图添加到父视图的某个位置
[self.view insertSubview:view5 aboveSubview:view1];//将view5添加到父视图,且在view1之上
[self.view insertSubview:view1 belowSubview:view];//将view1添加到父视图,且在_view之下
[self.view exchangeSubviewAtIndex:3 withSubviewAtIndex:2];//交换两个位置的视图
[self.view bringSubviewToFront:view5];//将某个子视图移到父视图的最前方
[self.view sendSubviewToBack:view1];//将某个子视图移到父视图的最底层
// Do any additional setup after loading the view, typically from a nib.
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"被点击");(点击之后的运行)
}
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);