navigation bar right bar button items spacing

前端 未结 10 2071
执念已碎
执念已碎 2021-01-31 16:47

I have created a with left bar button item added from storyboard, titleView and three right bar button items from code.

Here is the code:

override func         


        
10条回答
  •  离开以前
    2021-01-31 17:18

    You can also wire things up first in Storyboard.
    I have two right bar button items.

    (This is objective-c code, which you can modify for swift.)

    First create references to them in view controller.

    @interface MyViewController ()
        @property (weak, nonatomic) IBOutlet UIButton *smsButton;
        @property (weak, nonatomic) IBOutlet UIButton *checkoutButton;
    @end
    

    Then, in viewDidLoad, adjust their widths and heights.

    // Adjust right bar button item spacing.
    self.smsButton.frame = CGRectMake(0, 0, 30, 30);
    self.lockButton.frame = CGRectMake(0, 0, 30, 30);
    

提交回复
热议问题