iOS关于悬浮view的那些事

2016-06-28  本文已影响692人  coderJerry01

很多应用程序你会发现有一些固定不动的悬浮控件,例如你在滚动tableview时就会看到有固定的控件不动;

红色是button,黑色是view

代码如下:

- (void)test{

//

UIView *view_1 = [[UIView alloc] initWithFrame:CGRectMake(0, 300, 100, 30)];

view_1.backgroundColor = [UIColor blackColor];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

[button setTitle:@"button" forState:UIControlStateNormal];

button.frame = CGRectMake(0, 200, 100, 30);

button.backgroundColor = [UIColor redColor];

//把button贴在window上

[[[[UIApplication sharedApplication] windows] firstObject] addSubview:button];

//

[[[[UIApplication sharedApplication] windows] firstObject] addSubview:view_1];

//

}

上一篇 下一篇

猜你喜欢

热点阅读