左上角和右上角的按钮

来源:互联网 发布:网络上弹棉花什么意思 编辑:程序博客网 时间:2024/05/03 14:53

@implementation DiErYeViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.

//建立buttonUIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];button.frame = CGRectMake(0, 0, 40, 40);[self.view addSubview:button];[button setImage:[UIImage imageNamed:@"tb1"] forState:UIControlStateNormal];[button addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];// 实现左上角按钮self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];// 实现右上角按钮self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];

// 文字显示
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@”关闭” style:UIBarButtonItemStylePlain target:self action:@selector(clickButton:)];

}

// 实现点击的方法
- (void)clickButton:(UIButton *)button{

}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end

0 0
原创粉丝点击