UINavigationController
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeSystem]; //[UIButton buttonWithType:UIButtonTypeCustom];//显示真实图标颜色 myButton.frame = CGRectMake(0, 0, 30, 30); // myButton.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"home"]]; [myButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];//建议使用方式 // [myButton setTitle:@"返回" forState: UIControlStateNormal] ; UIBarButtonItem *backButton = [[UIBarButtonItem alloc]initWithCustomView:myButton]; UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeSystem]; myButton1.frame = CGRectMake(0, 0, 30, 30); // myButton.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"login"]];//无点击效果,保留色彩 [myButton1 setImage:[UIImage imageNamed:@"home"] forState:UIControlStateNormal];//建议使用方式 // [myButton setTitle:@"返回" forState: UIControlStateNormal] ; UIBarButtonItem *backButton1 = [[UIBarButtonItem alloc]initWithCustomView:myButton1]; self.navigationItem.leftBarButtonItem = backButton; self.navigationItem.rightBarButtonItem = backButton1;
时间: 2024-12-21 19:50:08