//获取屏幕宽度和高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
//声明:
@property (strong, nonatomic) UIButton *button;
//初始化button为全屏
self.button = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, SCREEN_WIDTH, SCREEN_HEIGHT)];
//设置代理
self.button.touchDelegate = self;
//添加button到屏幕
[self.view addSubview:self.button];
//设置button颜色为灰色
[_button setBackgroundColor:[UIColor clearColor]];
OC 添加Button在主屏幕上,设置全屏且为灰色
最新推荐文章于 2024-09-11 20:49:39 发布