美文网首页
iOS关于悬浮view的那些事

iOS关于悬浮view的那些事

作者: coderJerry01 | 来源:发表于2016-06-28 16:13 被阅读692次

很多应用程序你会发现有一些固定不动的悬浮控件,例如你在滚动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];

//

}

相关文章

网友评论

      本文标题:iOS关于悬浮view的那些事

      本文链接:https://www.haomeiwen.com/subject/uaytjttx.html