Tag: 前端

iOS:在导航栏正下方添加一个固定的图像

感觉这应该是相当简单的,但我迄今为止没有尝试过的工作。 简而言之,我想添加一个固定的图像就在我创build的UITableViewController导航栏下方,我创build编程。 换句话说,即使用户在表格视图中上下滚动(它基本上是导航栏的自定义拖放阴影),我也希望图像保持在导航栏的正下方。 我得到的最接近的是下面的代码(在UITableViewController的init方法中),它添加了图像,但不会在用户滚动时不让它移动。 // Add nav bar drop shadow UIImage *dropShadowImage = [UIImage imageNamed:@"NavBarDropShadow.png"]; UIImageView *dropShadowView = [[UIImageView alloc] initWithImage:dropShadowImage]; [self.view addSubview:dropShadowView]; 有没有一个简单的方法来添加一个图像添加到屏幕上编程,将其放在任何你喜欢的地方,并保持在那里,即使用户滚动? 感谢您的任何和所有的投入!

iOS:在自定义导航栏中定位导航栏button

我正在build立一个自定义导航栏的应用程序。 经过一番研究,我决定在UINavigationBar上使用一个类别来做这件事。 导航栏需要比平常大一点,以适应阴影。 这里是代码: #import "UINavigationBar+CustomWithShadow.h" @implementation UINavigationBar (CustomWithShadow) – (void)drawRect:(CGRect)rect { // Change the tint color in order to change color of buttons UIColor *color = [UIColor colorWithHue:0.0 saturation:0.0 brightness:0.0 alpha:0.0]; self.tintColor = color; // Add a custom background image to the navigation bar UIImage *image = [UIImage imageNamed:@"NavBar.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, 60)]; […]