Skip to content

Commit 494b95a

Browse files
committed
0.12.0
1 parent ef621cb commit 494b95a

7 files changed

Lines changed: 51 additions & 12 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
+ (May) lookup baseline reset issue with overflowing text
66

7+
* 0.12.0
8+
9+
+ Update `README.md`
10+
711
* 0.10.0 - 0.11.0
812

913
+ Added `MarsViewController`
277 KB
Loading
1.1 MB
Loading
573 KB
Loading
1.49 MB
Loading

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
# UILabel Typography Extensions 📐
2-
Set line height, letter spacing (and more) directly on `UILabel`.
2+
Set `UILabel` line height, letter spacing (and more).
33

44
```Swift
5-
let label = UILabel()
6-
label.text = "Hello World!"
7-
label.textColor = .label
8-
label.font = .preferredFont(forTextStyle: .largeTitle)
9-
// 🎉
10-
label.lineHeight = 100
11-
label.letterSpacing = 10
12-
label.underline = .double
13-
label.strikethrough = .patternDash
5+
let headerLabel = UILabel()
6+
headerLabel.text = "Mars"
7+
headerLabel.textColor = label
8+
headerLabel.font = UIFont(name: "HelveticaNeue-CondensedBlack", size: 100)
9+
headerLabel.lineHeight = 80
10+
headerLabel.letterSpacing = 100 * -0.02
1411
```
1512

16-
A single extension on `UILabel` that adds some typographic property (see above) using [**Objective-C Runtime**] (for stored properties on a Swift extension), [`NSAttributedString`] (for manage typographic properties), and [`NSKeyValueObservation`] (to be able to use the regular `text` property to manage text content).
13+
<p align="center"><img src="UILabel_Typography_Extensions/Documentation/UlLabel_Line_Height_Letter_Spacing_Extension.png" width="900"></p>
1714

1815
See the complementary article at [**UILabel line height, letter spacing and more** UILabel typography extensions].
1916

20-
> 🚧 **Work in progress**. I have high hopes to add leading and trailing image feature, as well as support for `UIButton`.
17+
<p align="center"><img src="UILabel_Typography_Extensions/Documentation/UILabel_Line_Height_Simulator_Figma_Overlay.png" width="900"></p>
18+
19+
## How it works
20+
21+
It is an extension on `UILabel` that adds some typographic properties using [**Objective-C Runtime**] (for stored properties on a Swift extension), [`NSAttributedString`] (for manage typographic properties), and [`NSKeyValueObservation`] (to be able to use the regular `text` property to manage text content).
22+
23+
<p align="center"><img src="UILabel_Typography_Extensions/Documentation/UILabel_Line_Height_NSAttributedString_BaselineOffset.png" width="900"></p>
24+
25+
It also takes care of `baselineOffset` values to keep the text content in the vertical center (right). By default, :NSAttributedString: sticks multiline label content to the top of the container view (left), which makes it hard to
26+
match the UI with the design specifications.
27+
28+
<p align="center"><img src="UILabel_Typography_Extensions/Documentation/UILabel_Line_Height_Xcode_Figma.png" width="900"></p>
29+
30+
Using this extension you can build screens that 100% match design specifications. More on that in the article at [**UILabel line height, letter spacing and more** UILabel typography extensions].
31+
2132

2233
## License
2334

UILabel_Typography_Extensions.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
5558DA4627DA1FA900A4A178 /* MockupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5558DA4527DA1FA900A4A178 /* MockupViewController.swift */; };
1717
55722E1E27DB6167002DE7DC /* MarsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55722E1D27DB6167002DE7DC /* MarsViewController.swift */; };
1818
55722E1F27DB63BC002DE7DC /* PlanetViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559E70FC27D90D0E00C00AD7 /* PlanetViewController.swift */; };
19+
557D5F8227DE08EB00A7DE15 /* UILabel_Line_Height_Simulator_Figma_Overlay.png in Resources */ = {isa = PBXBuildFile; fileRef = 557D5F8027DE08EB00A7DE15 /* UILabel_Line_Height_Simulator_Figma_Overlay.png */; };
20+
557D5F8327DE08EB00A7DE15 /* UlLabel_Line_Height_Letter_Spacing_Extension.png in Resources */ = {isa = PBXBuildFile; fileRef = 557D5F8127DE08EB00A7DE15 /* UlLabel_Line_Height_Letter_Spacing_Extension.png */; };
21+
557D5F8527DE09BB00A7DE15 /* UILabel_Line_Height_NSAttributedString_BaselineOffset.png in Resources */ = {isa = PBXBuildFile; fileRef = 557D5F8427DE09BB00A7DE15 /* UILabel_Line_Height_NSAttributedString_BaselineOffset.png */; };
22+
557D5F8727DE0AAC00A7DE15 /* UILabel_Line_Height_Xcode_Figma.png in Resources */ = {isa = PBXBuildFile; fileRef = 557D5F8627DE0AAC00A7DE15 /* UILabel_Line_Height_Xcode_Figma.png */; };
1923
559795E525A259E400A757A3 /* UIColor+Styles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559795E425A259E400A757A3 /* UIColor+Styles.swift */; };
2024
559FB34E25A4B1A200CE795D /* LineHeightViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 559FB34D25A4B1A200CE795D /* LineHeightViewController.swift */; };
2125
55A3EECE27D7F24C0002193A /* UIFont+Inspection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 55A3EECD27D7F24C0002193A /* UIFont+Inspection.swift */; };
@@ -47,6 +51,10 @@
4751
554AF31725961B6200A23E41 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4852
5558DA4527DA1FA900A4A178 /* MockupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockupViewController.swift; sourceTree = "<group>"; };
4953
55722E1D27DB6167002DE7DC /* MarsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarsViewController.swift; sourceTree = "<group>"; };
54+
557D5F8027DE08EB00A7DE15 /* UILabel_Line_Height_Simulator_Figma_Overlay.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = UILabel_Line_Height_Simulator_Figma_Overlay.png; sourceTree = "<group>"; };
55+
557D5F8127DE08EB00A7DE15 /* UlLabel_Line_Height_Letter_Spacing_Extension.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = UlLabel_Line_Height_Letter_Spacing_Extension.png; sourceTree = "<group>"; };
56+
557D5F8427DE09BB00A7DE15 /* UILabel_Line_Height_NSAttributedString_BaselineOffset.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = UILabel_Line_Height_NSAttributedString_BaselineOffset.png; sourceTree = "<group>"; };
57+
557D5F8627DE0AAC00A7DE15 /* UILabel_Line_Height_Xcode_Figma.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = UILabel_Line_Height_Xcode_Figma.png; sourceTree = "<group>"; };
5058
559795E425A259E400A757A3 /* UIColor+Styles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+Styles.swift"; sourceTree = "<group>"; };
5159
559E70FC27D90D0E00C00AD7 /* PlanetViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlanetViewController.swift; sourceTree = "<group>"; };
5260
559FB34D25A4B1A200CE795D /* LineHeightViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LineHeightViewController.swift; sourceTree = "<group>"; };
@@ -98,6 +106,17 @@
98106
path = Typography;
99107
sourceTree = "<group>";
100108
};
109+
557D5F7F27DE08DC00A7DE15 /* Documentation */ = {
110+
isa = PBXGroup;
111+
children = (
112+
557D5F8627DE0AAC00A7DE15 /* UILabel_Line_Height_Xcode_Figma.png */,
113+
557D5F8427DE09BB00A7DE15 /* UILabel_Line_Height_NSAttributedString_BaselineOffset.png */,
114+
557D5F8027DE08EB00A7DE15 /* UILabel_Line_Height_Simulator_Figma_Overlay.png */,
115+
557D5F8127DE08EB00A7DE15 /* UlLabel_Line_Height_Letter_Spacing_Extension.png */,
116+
);
117+
path = Documentation;
118+
sourceTree = "<group>";
119+
};
101120
558D107725A15277005DB3DA /* Deprecated */ = {
102121
isa = PBXGroup;
103122
children = (
@@ -140,6 +159,7 @@
140159
children = (
141160
554AF31725961B6200A23E41 /* README.md */,
142161
554A2DCF27D67B66008A4AE4 /* CHANGELOG.md */,
162+
557D5F7F27DE08DC00A7DE15 /* Documentation */,
143163
55F236A025912BBE0007BC69 /* UILabel_Typography_Extensions */,
144164
55F2369F25912BBE0007BC69 /* Products */,
145165
);
@@ -237,8 +257,12 @@
237257
isa = PBXResourcesBuildPhase;
238258
buildActionMask = 2147483647;
239259
files = (
260+
557D5F8327DE08EB00A7DE15 /* UlLabel_Line_Height_Letter_Spacing_Extension.png in Resources */,
240261
55F236AE25912BC30007BC69 /* LaunchScreen.storyboard in Resources */,
241262
554AF31825961B6200A23E41 /* README.md in Resources */,
263+
557D5F8727DE0AAC00A7DE15 /* UILabel_Line_Height_Xcode_Figma.png in Resources */,
264+
557D5F8527DE09BB00A7DE15 /* UILabel_Line_Height_NSAttributedString_BaselineOffset.png in Resources */,
265+
557D5F8227DE08EB00A7DE15 /* UILabel_Line_Height_Simulator_Figma_Overlay.png in Resources */,
242266
55F236A825912BC30007BC69 /* Assets.xcassets in Resources */,
243267
);
244268
runOnlyForDeploymentPostprocessing = 0;

0 commit comments

Comments
 (0)