Skip to content

Commit 92650eb

Browse files
author
Eric Wu
committed
增加接口,修复bug
1 parent 6180b60 commit 92650eb

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

CRBoostSwift/Classes/CRMath.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public func CRPointSacle(point: CGPoint, factor: CGFloat) -> CGPoint {
9595

9696
@discardableResult
9797
public func CRFrameCenter(rect: CGRect) -> CGPoint {
98-
return CGPoint(x: rect.midX, y: rect.midY)
98+
return CGPoint(x: rect.minX + rect.size.width / 2, y: rect.minY + rect.size.height / 2)
9999
}
100100

101101
@discardableResult
@@ -397,7 +397,6 @@ public func CRPresentActionSheet(title: String? = nil, msg: String? = nil, handl
397397
return alert
398398
}
399399

400-
401400
@discardableResult
402401
public func CRPresentAlert(title: String?, msg: String) -> UIAlertController {
403402
return CRPresentAlert(title: title, msg: msg, handler: nil, canel: NSLocalizedString("OK", comment: ""))

CRBoostSwift/Classes/Utility.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ public class Utility {
8989
}
9090
}
9191

92+
public class func main(task: @escaping CRVoidBlock) {
93+
if Thread.isMainThread {
94+
task()
95+
} else {
96+
DispatchQueue.main.async {
97+
task()
98+
}
99+
}
100+
}
101+
92102
// MARK: - View
93103

94104
public class func presentView(view: UIView, animated: Bool) {
@@ -102,24 +112,25 @@ public class Utility {
102112
}
103113

104114
// MARK: - storyboard
105-
public class func controllerInStoryboard( storyboard: String, identifier: String) -> UIViewController {
115+
116+
public class func controllerInStoryboard(storyboard: String, identifier: String) -> UIViewController {
106117
let ontroller = UIStoryboard(name: storyboard, bundle: nil).instantiateViewController(withIdentifier: identifier)
107118
return ontroller
108119
}
120+
109121
// MARK: - goUrl
110-
public class func goStringUrl(_ str: String?) {
111122

123+
public class func goStringUrl(_ str: String?) {
112124
guard var trimStr = str else { return }
113125
trimStr = trimStr.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) ?? ""
114126
goURL(URL(string: trimStr))
115127
}
116128

117129
public class func goURL(_ url: URL?) {
118-
guard let trimUrl = url else { return}
130+
guard let trimUrl = url else { return }
119131
if UIApplication.shared.canOpenURL(trimUrl) {
120132
if #available(iOS 10.0, *) {
121-
UIApplication.shared.open(trimUrl, options: [:]) { (_) in
122-
133+
UIApplication.shared.open(trimUrl, options: [:]) { _ in
123134
}
124135
} else {
125136
UIApplication.shared.openURL(trimUrl)

0 commit comments

Comments
 (0)