导航栏左右按钮 如何调左右距离
- 作者: 夏殇25474321
- 来源: 51数据库
- 2022-08-17
UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];
UIButton *settingButton = [UIButton buttonWithType:UIButtonTypeCustom];
settingButton.frame = CGRectMake(17, 0, 44, 44);
[settingButton addTarget:self action:@selector(settingAction:) forControlEvents:UIControlEventTouchUpInside];
[settingButton setImage:[UIImage imageNamed:@"btn_setting"] forState:UIControlStateNormal];
[rightView addSubview:settingButton];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightView];
推荐阅读
