iOS navigation布局 按钮修改

缑泓
2023-12-01
//设置左上角按钮
    UIButton* leftButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,40,25)];
    [leftButton setImage:[UIImage imageNamed:@"but_fanhui.png"]forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(backMain)forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem= leftItem;
    
    //设置右上角按钮
    UIButton* rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,40,25)];
    [rightButton setImage:[UIImage imageNamed:@"but_zhuce.png"]forState:UIControlStateNormal];
   [rightButton addTarget:self action:@selector(doRegister)forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem= rightItem;

 类似资料: