[英]Modified navigationbar causes issues on button item
In our project we wanted to change the size of navigationbar. 在我们的项目中,我们想更改导航栏的大小。 Have achieved it with
已经做到了
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
return CGSizeMake(self.superview.bounds.size.width, 55.0f);
}
@end
But the problem here is.. as you would see go button is little down from screen edge. 但这里的问题是,因为..你会看到走按钮是从屏幕边缘小了下来。 But I wanted it to be in ultimate corner of screen.
但我希望它位于屏幕的终极角落。 I use
backgroundColor:
, setTitle:forState:
methods for constructing look of go button. 我使用
backgroundColor:
, setTitle:forState:
用于构造go按钮外观的方法。 also back button to be vertically middle. 也将后退按钮设置为垂直居中。 How can I achieve that.
我该如何实现。 Tried Using
edgeInsets:
but no hope. 尝试使用
edgeInsets:
但没有希望。
Edit: Go button height is 10px less than barheight. 编辑:转到按钮的高度比barheight小10px。
if I give equal height. 如果我给等高。 Below is the result
以下是结果
in somewhat I have tried your coding.Check that 在某种程度上我已经尝试过您的编码。检查
UIButton *goBtn = [UIButton buttonWithType:UIButtonTypeCustom];
goBtn.frame = CGRectMake(0, 0, 63, 80);
goBtn.backgroundColor = [UIColor redColor];
UIView *goButtonView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 63, 50)];
NSLog(@"goButtonView bounds are - %@", NSStringFromCGRect([goButtonView bounds]));
goButtonView.bounds = CGRectOffset(goButtonView.bounds, -17, 0);
NSLog(@"goButtonView bounds are - %@", NSStringFromCGRect([goButtonView bounds]));
[goButtonView addSubview:goBtn];
UIBarButtonItem *goButton = [[UIBarButtonItem alloc] initWithCustomView:goButtonView];
self.navigationItem.rightBarButtonItem = goButton;
Below the references 参考文献下方
Issue with button on the left side of the uinavigation bar uinavigation栏左侧的按钮出现问题
UINavigationBar UIBarButtonItems much larger click area than required UINavigationBar UIBarButtonItems点击区域比要求的大得多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.