自定义NavgationBar返回按钮(Swift & OC)
发布时间:2020-12-14 01:35:25 所属栏目:百科 来源:网络整理
导读:Objective-C UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(0,40,40); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; [btn setTitle:@"返回" forState:UIControlSt
Objective-C UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.frame = CGRectMake(0,40,40); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn]; [btn setTitle:@"返回" forState:UIControlStateNormal]; [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; Swift 版本 func createRightBarButtonItem() { buttonRight = UIButton.init(type: UIButtonType.Custom) buttonRight.frame = CGRectMake(0,40) self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: buttonRight) buttonRight.setTitle("Edit",forState: UIControlState.Normal) buttonRight.addTarget(self,action: Selector("jion:"),forControlEvents: UIControlEvents.TouchUpInside) } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |