UIBarButton Item on screen edge in iOS 8 when used in standalone view

后端 未结 3 420
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 13:13

In my UINavigation bar added to a XIB with a number of UIViews the positioning of the left and right bar button item is way off:

3条回答
  •  误落风尘
    2021-01-17 14:05

    Add button using the below code, it will definitely work.

    CGRect frameimg = CGRectMake(0, 0, 60, 30);
    UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
    //[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
    [someButton setTitle:@"Update" forState:UIControlStateNormal];
    [someButton addTarget:self action:@selector(updateProfile)
         forControlEvents:UIControlEventTouchUpInside];
    [someButton setShowsTouchWhenHighlighted:YES];
    UIBarButtonItem *menuButton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
    self.navigationItem.rightBarButtonItem = menuButton;
    

提交回复
热议问题