改变导航栏左边按钮的点击区域

UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(0, 0, 30, 30);
    [leftBtn setImage:[UIImage imageNamed:@"jiahao"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(CreatTalking) forControlEvents:UIControlEventTouchUpInside];
    UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 20, 20)];
    [customView addSubview:leftBtn];
    customView.userInteractionEnabled = NO;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:customView];

猜你喜欢

转载自blog.csdn.net/YY_Seven/article/details/50846526