【发布时间】:2013-05-22 08:58:01
【问题描述】:
我为我的项目实现了这个自定义 NavigationBar 类:Video with Issue
#import "PTTNavigationBar.h"
@implementation PTTNavigationBar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
// Overriding drawRect: perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
UIImage *navBarImage = UIIMAGE_NAMED( kNavBarBackGroundImage );
[navBarImage drawInRect:CGRectMake(0, 0, NAVBAR_SIZE.width , NAVBAR_SIZE.height)];
[self setBackgroundColor:[UIColor clearColor]];
}
- (CGSize)sizeThatFits:(CGSize)size {
//[self setTitleVerticalPositionAdjustment:-12 forBarMetrics:UIBarMetricsDefault];
CGRect frame = [UIScreen mainScreen].applicationFrame;
CGSize newSize = CGSizeMake(frame.size.width , NAVBAR_SIZE.height);
[self layoutSubviews];
return newSize;
}
-(void) layoutSubviews
{
[super layoutSubviews];
[self setBackgroundColor:[UIColor clearColor]];
for (UIView *view in self.subviews)
{
CGRect frame = view.frame;
frame.origin.y = 6;
view.frame = frame;
}
}
@end
任何人都可以帮助我吗? 谢谢
【问题讨论】:
-
你是如何添加 barButtonItems 的?它们是自定义按钮吗?
-
它是一个后退按钮。一个默认的
-
这是iOS的默认功能,您可以在设置应用程序中查看。如果您真的想限制触摸,那么我的答案将起作用。
-
@prasaddevadiga 设置应用程序和默认功能是什么意思,抱歉?
-
您可以在 iPhone 设置应用中查看。它是导航栏按钮的一个功能。
标签: ios uibutton custom-controls uinavigationbar uinavigationitem