导航栏全透明效果, 只保留左右两个按钮, 如何实现?
2016-02-28 15:47
281 查看
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forBarMetrics:UIBarMetricsCompact];
self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
for (id view in self.navigationController.navigationBar.subviews)
{
if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")])
{
for (id i in [view subviews])
{
if ([i isKindOfClass:[UIImageView class]])
{
[i removeFromSuperview];
}
}
}
}
[[[[self.navigationController.navigationBar.subviews firstObject] subviews] firstObject] removeFromSuperview];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"More" style:UIBarButtonItemStyleDone target:self action:@selector(more)];
北京--疯子
+ (UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
[self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColor clearColor]]];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
for (id view in self.navigationController.navigationBar.subviews)
{
if ([view isKindOfClass:NSClassFromString(@"_UINavigationBarBackground")])
{
for (id i in [view subviews])
{
if ([i isKindOfClass:[UIImageView class]])
{
[i removeFromSuperview];
}
}
}
}
[[[[self.navigationController.navigationBar.subviews firstObject] subviews] firstObject] removeFromSuperview];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add)];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"More" style:UIBarButtonItemStyleDone target:self action:@selector(more)];
北京--疯子
+ (UIImage *)imageWithColor:(UIColor *)color
{
CGRect rect = CGRectMake(0, 0, 1, 1);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextFillRect(context, rect);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
相关文章推荐
- Nginx + Tomcat 动静分离实现负载均衡
- DFS基础(1)
- UVa 1584 - Circular Sequence
- Android项目中如何用好构建神器Gradle?
- 006_Http之路径
- MT7620A 编译过程on gentoo
- LintCode- 恢复IP地址
- Java socket编程
- bzoj1861 book书架 splay
- The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- kidd风的IOS日志之第三方-SDWebImage的使用
- gpg-agent具体配置
- 堆排序
- java Junit 测试中异常处理
- ApplicationContext对象的获取方式
- Block基础详解
- 链表翻转
- 安装VMware Sphere ESXi 5.5
- 快速排序
- GC 日志分析工具 —— GChisto