UIView
extension UIView
-
角标view
Declaration
Swift
public var badgeView: BadgeControl { get set } -
获取view父View中的MaskPopupView
Declaration
Swift
public var maskPopupView: MaskPopupView? { get }
-
为view绑定字符串数据
Declaration
Swift
public var dataStr: String { get set } -
为view绑定Any类型数据
Declaration
Swift
public var dataAny: Any { get set }
-
获取指定子视图
Declaration
Swift
public func getSubView(name: String) -> [UIView] -
获取所有子视图
Declaration
Swift
public func getAllSubViews() -> [UIView] -
移除所有子视图
Declaration
Swift
public func removeAllSubview() -
同时添加多个视图
Declaration
Swift
public func addSubviews(_ subviews: UIView...)Parameters
subviews子视图数组
-
获取最近的指定view类型的父view
Declaration
Swift
public func getParentView(viewType: AnyClass) -> UIView?Parameters
viewTypeview类型
-
获取view所在的ViewController
利用UIResponder的next,即响应链机制
Declaration
Swift
public var firstViewController: UIViewController? { get } -
设置View部分圆角,若使用自动布局,应在设置宽高约束后使用 示例:view.setCorner(size:5, roundingCorners:[.topLeft,.topRight]),
Declaration
Swift
public func setCorner(size: CGFloat, roundingCorners: UIRectCorner)Parameters
size圆角大小
roundingCorners圆角位置
-
转为Image
Declaration
Swift
public func toImage() -> UIImage?Return Value
UIImage
-
Undocumented
Declaration
Swift
public func rightBorder(width: CGFloat, borderColor: UIColor) -
Undocumented
Declaration
Swift
public func leftBorder(width: CGFloat, borderColor: UIColor) -
Undocumented
Declaration
Swift
public func topBorder(width: CGFloat, borderColor: UIColor) -
Undocumented
Declaration
Swift
public func buttomBorder(width: CGFloat, borderColor: UIColor)
-
为View添加渐变图层
Declaration
Swift
public func gradientColor(startPoint: CGPoint, endPoint: CGPoint, colors: [UIColor], height: CGFloat? = nil)Parameters
startPoint起始点
endPoint终止点
colors渐变色数组
-
移除渐变图层
Declaration
Swift
public func removeGradientLayer()
-
闭包
Declaration
Swift
public typealias GestureClosures = (UIGestureRecognizer) -> Void -
点击
Declaration
Swift
@discardableResult public func addTapGesture(disEnabledtimeInterval: CGFloat = 0.5, _ gesture: @escaping GestureClosures) -> UIViewParameters
disEnabledtimeInterval不可用时间,默认时间为0.5s
gesture手势回调
-
捏合
Declaration
Swift
@discardableResult public func addPinchGesture(_ gesture: @escaping GestureClosures) -> UIView -
旋转
Declaration
Swift
@discardableResult public func addRotationGesture(_ gesture: @escaping GestureClosures) -> UIView -
滑动
Declaration
Swift
@discardableResult public func addSwipeGesture(_ gesture: @escaping GestureClosures) -> UIView -
长按
Declaration
Swift
@discardableResult public func addLongPressGesture(_ gesture: @escaping GestureClosures) -> UIView
-
扩大点击区域 此方法只对UIView的子类起作用,子类需要重写hitTest方法
Declaration
Swift
public func setEnlargeEdge(top: CGFloat, right: CGFloat, bottom: CGFloat, left: CGFloat)Parameters
top顶部扩大长度
right右边扩大长度
bottom底部扩大长度
left左边扩大长度
-
圆角
Declaration
Swift
@IBInspectable public var csCornerRadius: CGFloat { get set } -
边框宽度
Declaration
Swift
@IBInspectable public var csBorderWidth: CGFloat { get set } -
边框颜色
Declaration
Swift
@IBInspectable public var csBorderColor: UIColor { get set } -
加载 xib view 类方法
Declaration
Swift
@objc public class func initByNib(bundle: Bundle = Bundle.main) -> `Self`?
View on GitHub
UIView Extension Reference