方法一
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[backBtn setTitle:@"返回" forState:UIControlStateNormal];
backBtn.frame = CGRectMake(0, 0, 40, 40);
[backBtn addTarget:self action:@selector(GoTop) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *layerBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationController.navigationBar.topItem.leftBarButtonItem = layerBtnItem;
方法二
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[backBtn setTitle:@"返回" forState:UIControlStateNormal];
backBtn.frame = CGRectMake(0, 0, 40, 40);
[backBtn addTarget:self action:@selector(GoTop) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *layerBtnItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationController.navigationItem.leftBarButtonItem=layerBtnItem;
沒有留言:
張貼留言