UINavigationBar UIBarButtonItems much larger click area than required

后端 未结 8 1441
遇见更好的自我
遇见更好的自我 2020-12-08 09:40

hopefully someone can help me out- iv\'e scoured the net for the answer and cannot find one-

the UIBarButtonItems added to UINavigationBar have a much larger click a

相关标签:
8条回答
  • 2020-12-08 10:31

    This is the only solution I found. Create a container of the custom button:

    //Create a container for the button
    UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 55, 44)];
    
    //Create a smaller button
    UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 25)];
    [closeButton setTitle:@"Cancel" forState:UIControlStateNormal];
    //center the title
    closeButton.titleEdgeInsets = UIEdgeInsetsMake(23, 0, 0, 0);
    
    [buttonContainer addSubview:closeButton];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:buttonContainer];
    
    0 讨论(0)
  • 2020-12-08 10:31

    Trying to work around the UINavigation Bar padding may run you into trouble when you submit to the app store. It would be easier to add the padding to your custom heading. As a "fat thumber" I have learned to appreciate the HIG.

    0 讨论(0)
提交回复
热议问题