diff --git a/CHANGELOG.md b/CHANGELOG.md index c1806f9..f134252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ --- -## [V1.3.0](https://github.com/youngsoft/TangramKit/releases/tag/1.3.0)(2018/09/29) +## [V1.3.1](https://github.com/youngsoft/TangramKit/releases/tag/1.3.1)(2018/09/21) #### Fixed -1. 为实现对Swift4.0的支持而修复了所有编译告警的问题。 +1. 为实现对Swift4.0/4.2的支持而修复了所有编译告警的问题。 2. 修复了浮动布局TGFloatLayout中的子视图在设置尺寸为TGWeight类型时的一个比例计算的错误问题。 3. 实现对iPhoneXR、iPhoneXS、iPhoneXSMAX的tg_padding的安全区缩进的改进支持。 4. 实现了在Application Extension中使用布局库时报UIApplication对象不支持或者不存在的问题。 diff --git a/TangramKit.podspec b/TangramKit.podspec index ff422b7..7ae14d5 100644 --- a/TangramKit.podspec +++ b/TangramKit.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "TangramKit" - s.version = "1.3.0" + s.version = "1.3.1" s.summary = "TangramKit is A powerful iOS UI framework. It integrated the Android layout,AutoLayout,SizeClass, HTML/CSS float and flexbox functions." s.description = <<-DESC diff --git a/TangramKit.xcodeproj/project.pbxproj b/TangramKit.xcodeproj/project.pbxproj index f60bf95..a6a1f6a 100644 --- a/TangramKit.xcodeproj/project.pbxproj +++ b/TangramKit.xcodeproj/project.pbxproj @@ -832,7 +832,7 @@ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -862,7 +862,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 4.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/TangramKit/TGBaseLayout.swift b/TangramKit/TGBaseLayout.swift index 14fb041..4a412f2 100644 --- a/TangramKit/TGBaseLayout.swift +++ b/TangramKit/TGBaseLayout.swift @@ -1384,6 +1384,7 @@ open class TGBaseLayout: UIView,TGLayoutViewSizeClass { /// - target: 事件的处理对象,如果设置为nil则表示取消事件。 /// - action: 事件的处理动作,格式为:func handleAction(sender:TGBaseLayout) /// - controlEvents: 支持的事件类型,目前只支持:touchDown、touchUpInside、touchCancel这三个事件。 + #if swift(>=4.2) public func tg_setTarget(_ target: NSObjectProtocol?, action: Selector?, for controlEvents: UIControl.Event) { if _tgTouchEventDelegate == nil @@ -1393,6 +1394,19 @@ open class TGBaseLayout: UIView,TGLayoutViewSizeClass { _tgTouchEventDelegate?.setTarget(target, action: action, for: controlEvents) } + #else + public func tg_setTarget(_ target: NSObjectProtocol?, action: Selector?, for controlEvents: UIControlEvents) + { + + + if _tgTouchEventDelegate == nil + { + _tgTouchEventDelegate = TGTouchEventDelegate(self) + } + + _tgTouchEventDelegate?.setTarget(target, action: action, for: controlEvents) + } + #endif /** 设置布局按下时背景的高亮的颜色。只有设置了tg_setTarget方法后此属性才生效。 @@ -2018,13 +2032,13 @@ open class TGBaseLayout: UIView,TGLayoutViewSizeClass { if let t = lsc.width.sizeVal { //约束冲突:宽度依赖的视图不是父视图 - assert(t.view == newSuperview, "Constraint exception!! \(self)width dependent on:\(t.view) is not superview") + assert(t.view == newSuperview, "Constraint exception!! \(self)width dependent on:\(t.view!) is not superview") } if let t = lsc.height.sizeVal { //约束冲突:高度依赖的视图不是父视图 - assert(t.view == newSuperview, "Constraint exception!! \(self)height dependent on:\(t.view) is not superview") + assert(t.view == newSuperview, "Constraint exception!! \(self)height dependent on:\(t.view!) is not superview") } #endif @@ -3574,6 +3588,8 @@ private class TGTouchEventDelegate TGTouchEventDelegate._CurrentLayout = nil } + #if swift(>=4.2) + func setTarget(_ target: NSObjectProtocol?, action: Selector?, for controlEvents: UIControl.Event) { //just only support these events @@ -3595,6 +3611,30 @@ private class TGTouchEventDelegate } } + #else + + func setTarget(_ target: NSObjectProtocol?, action: Selector?, for controlEvents: UIControlEvents) + { + //just only support these events + switch controlEvents { + case UIControlEvents.touchDown: + _touchDownTarget = target + _touchDownAction = action + break + case UIControlEvents.touchUpInside: + _touchUpTarget = target + _touchUpAction = action + break + case UIControlEvents.touchCancel: + _touchCancelTarget = target + _touchCancelAction = action + break + default: + return + } + } + + #endif func touchesBegan(_ touches: Set, with event: UIEvent?) { diff --git a/TangramKit/TGPathLayout.swift b/TangramKit/TGPathLayout.swift index 4bea0fe..9972cc3 100644 --- a/TangramKit/TGPathLayout.swift +++ b/TangramKit/TGPathLayout.swift @@ -385,12 +385,24 @@ open class TGPathLayout : TGBaseLayout,TGPathLayoutViewSizeClass { } } + #if swift(>=4.2) + + open override func sendSubviewToBack(_ view: UIView) { + if tg_originView == view { + return + } + super.sendSubviewToBack(view) + } + + #else + open override func sendSubview(toBack view: UIView) { if tg_originView == view { return } super.sendSubview(toBack: view) } + #endif open override func willRemoveSubview(_ subview: UIView) { super.willRemoveSubview(subview) diff --git a/TangramKit/TangramKit.swift b/TangramKit/TangramKit.swift index c2d675a..b790830 100644 --- a/TangramKit/TangramKit.swift +++ b/TangramKit/TangramKit.swift @@ -53,7 +53,7 @@ */ -//Current version is 1.3.0, please open: https://github.com/youngsoft/TangramKit/blob/master/CHANGELOG.md to show the changes. +//Current version is 1.3.1, please open: https://github.com/youngsoft/TangramKit/blob/master/CHANGELOG.md to show the changes.