Skip to content

Commit 06d3152

Browse files
committed
Added tinting for images.
1 parent 0285e20 commit 06d3152

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

Example App/iOS Example/Controllers/PresetsController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class PresetsController: SPDiffableTableController {
9999
name: "Custom Image",
100100
title: "Custom Image",
101101
message: "Passed UIImage object for preset with style custom.",
102-
preset: .custom(UIImage.init(systemName: "pencil.and.outline")!.withRenderingMode(.alwaysOriginal))
102+
preset: .custom(UIImage.init(systemName: "pencil.and.outline")!.withRenderingMode(.alwaysTemplate))
103103
),
104104
]
105105
}

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ I tried to recreate Apple's alerts as much as possible. You can find these alert
2222
- [Layout](#layout)
2323
- [Haptic](#haptic)
2424
- [Spinner](#spinner)
25-
- [Appearance](#appearance)
25+
- [Colors](#colors)
26+
- [Global Appearance](#global-appearance)
2627
- [SwiftUI](#swiftui)
2728
- [Russian Community](#russian-community)
2829

@@ -38,7 +39,7 @@ Once you have your Swift package set up, adding as a dependency is as easy as ad
3839

3940
```swift
4041
dependencies: [
41-
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.0.0"))
42+
.package(url: "https://github.com/ivanvorobei/SPAlert", .upToNextMajor(from: "4.0.1"))
4243
]
4344
```
4445

@@ -147,7 +148,18 @@ alertView.dismiss()
147148
SPAlert.dismiss()
148149
```
149150

150-
### Appearance
151+
### Colors
152+
153+
For change color of icon, simple set tint color for any preset:
154+
155+
```swift
156+
alertView.iconView?.tintColor = .systemRed
157+
158+
//If you set custom image, don't forget set rendering mode:
159+
UIImage(systemName: "pencil.and.outline")!.withRenderingMode(.alwaysTemplate)
160+
```
161+
162+
### Global Appearance
151163

152164
Also you can change some default values for alerts. For example you can change default duration and corner radius for alert with next code:
153165

SPAlert.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22

33
s.name = 'SPAlert'
4-
s.version = '4.0.0'
4+
s.version = '4.0.1'
55
s.summary = 'Native alert from Apple Music & Feedback. Contains Done, Heart & Message and other presets. Support SwiftUI.'
66
s.homepage = 'https://github.com/ivanvorobei/SPAlert'
77
s.source = { :git => 'https://github.com/ivanvorobei/SPAlert.git', :tag => s.version }

Sources/SPAlert/SPAlertView.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ open class SPAlertView: UIView {
145145
style.lineSpacing = 3
146146
style.alignment = .center
147147
label.attributedText = NSAttributedString(string: text, attributes: [.paragraphStyle: style])
148+
label.textColor = defaultContentColor
148149
titleLabel = label
149150
addSubview(label)
150151
}
@@ -157,12 +158,14 @@ open class SPAlertView: UIView {
157158
style.lineSpacing = 2
158159
style.alignment = .center
159160
label.attributedText = NSAttributedString(string: text, attributes: [.paragraphStyle: style])
161+
label.textColor = defaultContentColor
160162
subtitleLabel = label
161163
addSubview(label)
162164
}
163165

164166
private func setIcon(for preset: SPAlertIconPreset) {
165167
let view = preset.createView()
168+
view.tintColor = defaultContentColor
166169
self.iconView = view
167170
addSubview(view)
168171
}
@@ -208,11 +211,6 @@ open class SPAlertView: UIView {
208211

209212
self.completion = completion
210213

211-
let contentСolor = defaultContentColor
212-
titleLabel?.textColor = contentСolor
213-
subtitleLabel?.textColor = contentСolor
214-
iconView?.tintColor = contentСolor
215-
216214
alpha = 0
217215
setFrame()
218216
transform = transform.scaledBy(x: self.presentDismissScale, y: self.presentDismissScale)

0 commit comments

Comments
 (0)