A Swift implementation for LTNavigationBar
来源:互联网 发布:游戏交易网站源码 编辑:程序博客网 时间:2024/05/16 16:57
// A Swift implementation for LTNavigationBar
extension UINavigationBar { private struct AssociatedKeys { static var overlayKey = "overlayKey" static var emptyImageKey = "emptyImageKey" } var overlay: UIView? { get { return objc_getAssociatedObject(self, &AssociatedKeys.overlayKey) as? UIView } set { objc_setAssociatedObject(self, &AssociatedKeys.overlayKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) } } var emptyImage: UIImage? { get { return objc_getAssociatedObject(self, &AssociatedKeys.emptyImageKey) as? UIImage } set { objc_setAssociatedObject(self, &AssociatedKeys.emptyImageKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC)) } } func lt_setBackgroundColor(backgroundColor: UIColor?) { if var view = self.overlay { self.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) view = UIView(frame: CGRect(x: 0, y: -20, width: UIScreen.mainScreen().bounds.width, height: CGRectGetHeight(self.bounds) + 20)) view.userInteractionEnabled = false view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight self.insertSubview(view, atIndex: 0) } self.overlay?.backgroundColor = backgroundColor } func lt_setTranslationY(translationY: CGFloat) { self.transform = CGAffineTransformMakeTranslation(0, translationY) } func lt_setContentAlpha(alpha: CGFloat) { if self.overlay == nil { self.lt_setBackgroundColor(self.barTintColor) } self.setAlpha(alpha, forSubviewsOfView: self) if alpha == 1 { if self.emptyImage == nil { self.emptyImage = UIImage() } self.backIndicatorImage = self.emptyImage } } func setAlpha(aplha: CGFloat, forSubviewsOfView view: UIView) { for subview in view.subviews { if let view = subview as? UIView { if view == self.overlay { continue } view.alpha = alpha self.setAlpha(alpha, forSubviewsOfView: view) } } } func lt_reset() { self.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default) self.shadowImage = nil self.overlay?.removeFromSuperview() self.overlay = nil }}
0 0
- A Swift implementation for LTNavigationBar
- DWR: a nice choice for your ajax implementation
- Implementation Strategies for SAP R/3 in a Multinational Organization
- Bigtable: A Distributed Storage System for Structured Data : part5 Implementation
- Table for BAdI Implementation
- Chord implementation for Peersim
- Invalid Swift Support / invalid implementation of swift
- No implementation found for native...
- 译文:Chord implementation for Peersim
- TURF: New Methods for Implementation
- No implementation found for native
- Very simple A* algorithm implementation
- A SoundEx implementation in .NET
- A CRC8 Implementation In C#
- A CRC32 Implementation In C#
- A Simple HTTP Server Implementation
- Codeforces 672A(implementation)
- Swift在for循环中报错'++' is not a binary operator
- Ubuntu LAMP 环境配置
- 解决IDE编写JAVA读取文件的路径问题
- dicards qualifiers
- 122页21题
- Window 下 Docker的安装
- A Swift implementation for LTNavigationBar
- golang xml marshal对应的struct两种表示方法
- [Modernizr]-----HTML5和CSS3开发利器
- 用Fragment做Tal切换栏目
- 排序算法之归并排序
- Android 网络框架学习之OKHttp
- Java反射生成json和解析json
- java变量初始化
- css去掉iPhone、iPad默认按钮样式