Skip to content

Commit bc94073

Browse files
committed
0.2.1
1 parent 0a8281b commit bc94073

7 files changed

Lines changed: 16 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# CHANGELOG
22

3+
* Doing
34

4-
* Feature/Empty_Label_Support/0.2.0
5+
+ (May) lookup baseline reset issue with overflowing text
6+
7+
* Feature/Empty_Label_Support/0.2.0 - 0.2.1
58

69
+ Added `oldText` and `newText` parameters to `onTextChange` observer
710
+ Renamed `placeholder` to `cache`

UILabel_Typography_Extensions/Typography/UILabel+Typograpy.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension UILabel: TypographyExtensions {
5757
.paragraphStyle,
5858
value: (paragraphStyle ?? NSParagraphStyle())
5959
.mutable
60-
.withProperty(textAlignment, for: \.alignment)
60+
// .withProperty(textAlignment, for: \.alignment)
6161
.withProperty(lineHeight, for: \.minimumLineHeight)
6262
.withProperty(lineHeight, for: \.maximumLineHeight)
6363
)
@@ -72,7 +72,9 @@ extension UILabel: TypographyExtensions {
7272
if oldText.count == 0,
7373
newText.count > 0,
7474
let newText = newText {
75+
let alignment = textAlignment
7576
self.attributedText = NSAttributedString(string: newText, attributes: cachedAttributes)
77+
self.textAlignment = alignment
7678
}
7779

7880
// Update attributed string layout due to (unknown) UIKit internals.

UILabel_Typography_Extensions/View/EmptyViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class EmptyViewController: UIViewController {
2323
$0.showGrid = true
2424
$0.lineHeight = CGFloat(87)
2525
$0.underline = .single
26-
$0.textAlignment = .center
2726

2827
// Set text after.
2928
$0.text = loremIpsum
29+
$0.textAlignment = .right
3030

3131
}.inspect
3232

UILabel_Typography_Extensions/View/LineHeightViewController.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
class LineHeightViewController: UIViewController {
1212

13-
let text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
13+
let text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
1414

1515
var label: UILabel!
1616
var sliderObserver: Observer<UISlider, Float>!
@@ -27,6 +27,7 @@ class LineHeightViewController: UIViewController {
2727
$0.numberOfLines = 0
2828
$0.showGrid = true
2929
$0.underline = .single
30+
$0.textAlignment = .center
3031
self.label = $0
3132
}
3233
.with(text: text),

UILabel_Typography_Extensions/View/LoremIpsumViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
class LoremIpsumViewController: UIViewController {
1212

13-
let loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
13+
let loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." // Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
1414

1515
lazy var body = UIStackView()
1616
.vertical(spacing: 10)
@@ -19,7 +19,7 @@ class LoremIpsumViewController: UIViewController {
1919
UILabel()
2020
.with {
2121
$0.textColor = .label
22-
$0.font = .preferredFont(forTextStyle: .headline)
22+
$0.font = UIFont.newYork(ofSize: 1024 / 26.0 / 2.0) // .preferredFont(forTextStyle: .headline)
2323
$0.letterSpacing = 1
2424
$0.lineHeight = 50
2525
}

UILabel_Typography_Extensions/View/MenuViewController.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class MenuViewController: UIViewController {
3636
.with(title: "Manual Label Styling")
3737
.onTouchUpInside { [unowned self] in
3838
self.present(ManualViewController(), animated: true)
39-
}
40-
,
39+
},
4140
UIButton()
4241
.with(title: "Empty Label Styling")
4342
.onTouchUpInside { [unowned self] in
@@ -80,7 +79,7 @@ class MenuViewController: UIViewController {
8079

8180
override func viewDidAppear(_ animated: Bool) {
8281
super.viewDidAppear(animated)
83-
self.present(EmptyViewController(), animated: true)
82+
// self.present(EmptyViewController(), animated: true)
8483
}
8584
}
8685

UILabel_Typography_Extensions/View/UIButton+Styles.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ extension UIButton {
1414
with {
1515
$0.titleLabel?.textColor = .systemBackground
1616
$0.titleLabel?.backgroundColor = .systemBlue
17-
$0.titleLabel?.letterSpacing = 5
17+
$0.titleLabel?.letterSpacing = 2
1818
$0.titleLabel?.lineHeight = 50
1919
$0.titleLabel?.textAlignment = .center
2020
$0.titleLabel?.lineBreakMode = .byTruncatingMiddle
2121
$0.titleLabel?.pin(to: $0, insets: UIEdgeInsets.zero)
2222
_ = $0.titleLabel?.withImages
2323
$0.setTitleColor(.systemBackground, for: .normal)
2424
$0.setAttributedTitle($0.titleLabel?.attributedText, for: .normal)
25-
$0.layer.cornerRadius = 5
25+
$0.layer.cornerRadius = 25
2626
$0.clipsToBounds = true
2727
}
2828
}
@@ -34,13 +34,4 @@ extension UIButton {
3434
$0.setTitle(title, for: .normal)
3535
}
3636
}
37-
38-
func with(title: String, target: Any, selector: Selector) -> Self {
39-
self
40-
.withButtonStyle
41-
.with {
42-
$0.setTitle(title, for: .normal)
43-
$0.addTarget(target, action: selector, for: .touchUpInside)
44-
}
45-
}
4637
}

0 commit comments

Comments
 (0)