-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from 0xLeif/develop
Version 1.3
- Loading branch information
Showing
18 changed files
with
629 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// UIButton+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIButton { | ||
@discardableResult | ||
func set(titleColor: UIColor?, | ||
forState state: UIControl.State = .normal) -> Self { | ||
setTitleColor(titleColor, for: state) | ||
|
||
return self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// UIControl+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIControl { | ||
/// Set `isEnabled` for the view | ||
@discardableResult | ||
func enabled(if value: Bool = true) -> Self { | ||
isEnabled = value | ||
|
||
return self | ||
} | ||
|
||
/// Set `isEnabled` to `true` for the view | ||
@discardableResult | ||
func enable() -> Self { | ||
enabled(if: true) | ||
} | ||
|
||
/// Set `isEnabled` to `false` for the view | ||
@discardableResult | ||
func disable() -> Self { | ||
enabled(if: false) | ||
} | ||
|
||
@discardableResult | ||
func tint(color: UIColor?) -> Self { | ||
tintColor = color | ||
|
||
return self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// UIImage+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIImage { | ||
var template: UIImage { | ||
guard renderingMode != .alwaysTemplate else { | ||
return self | ||
} | ||
|
||
return withRenderingMode(.alwaysTemplate) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Sources/SwiftUIKit/Extensions/UIImageView+SwiftUIKit.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// UIImageView+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UIImageView { | ||
@discardableResult | ||
func templateImage() -> Self { | ||
image = image?.template | ||
|
||
return self | ||
} | ||
|
||
@discardableResult | ||
func tint(color: UIColor?) -> Self { | ||
tintColor = color | ||
|
||
return self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// UISlider+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UISlider { | ||
@discardableResult | ||
func set(thumbImage: UIImage?, | ||
forState state: UIControl.State = .normal) -> Self { | ||
setThumbImage(thumbImage, for: state) | ||
|
||
return self | ||
} | ||
|
||
@discardableResult | ||
func tint(thumbColor: UIColor?) -> Self { | ||
thumbTintColor = thumbColor | ||
|
||
return self | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// UISwitch+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UISwitch { | ||
@discardableResult | ||
func turn(on: Bool) -> Self { | ||
DispatchQueue.main.async { | ||
self.isOn = on | ||
} | ||
|
||
return self | ||
} | ||
|
||
@discardableResult | ||
func turnOn() -> Self { | ||
turn(on: true) | ||
} | ||
|
||
@discardableResult | ||
func turnOff() -> Self { | ||
turn(on: false) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SwiftUIKit/Extensions/UITextField+SwiftUIKit.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// UITextField+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UITextField { | ||
@discardableResult | ||
func text(color: UIColor?) -> Self { | ||
textColor = color | ||
|
||
return self | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// UITextView+SwiftUIKit.swift | ||
// SwiftUIKit | ||
// | ||
// Created by Zach Eriksen on 7/7/20. | ||
// | ||
|
||
import UIKit | ||
|
||
public extension UITextView { | ||
@discardableResult | ||
func text(color: UIColor?) -> Self { | ||
textColor = color | ||
|
||
return self | ||
} | ||
|
||
@discardableResult | ||
func tint(color: UIColor?) -> Self { | ||
tintColor = color | ||
|
||
return self | ||
} | ||
|
||
@discardableResult | ||
func set(delegate: UITextViewDelegate?) -> Self { | ||
self.delegate = delegate | ||
|
||
return self | ||
} | ||
} |
Oops, something went wrong.