【发布时间】:2019-11-13 02:05:40
【问题描述】:
我有一个 UIView 类,在 xib 中我也有一个 MainView,它是一个 UIView。我想将 UIButton 作为底部视图添加到视图中。我需要在 MainView 和底部视图之间提供底部空间 16。我该怎么做?
self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.MainView.bounds.size.height +30, self.MainView.bounds.size.width, 40.0)];
[self.bottomView setBackgroundColor:[UIColor greenColor]];
self.selectBtn= [UIButton buttonWithType: UIButtonTypeRoundedRect];
[self.selectBtn setFrame:CGRectMake(0,20,100,40)];
[self.selectBtn setTitle:@"Select" forState:UIControlStateNormal];
[self.selectBtn addTarget:self action:@selector(selectButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
[self.bottomView addSubview:self.selectBtn];
[self addSubview:self.bottomView];
【问题讨论】:
-
google iOS 自动布局教程
标签: ios objective-c uiview uibutton