Skip to content

Commit b7bb6ef

Browse files
committed
Added initialization
1 parent ea48418 commit b7bb6ef

File tree

5 files changed

+258
-3
lines changed

5 files changed

+258
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Arts/
2+
xcuserdata/

DynamicFontSizeExample.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
29F202581CA13E4E00AA0746 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29F202561CA13E4E00AA0746 /* Main.storyboard */; };
1313
29F2025A1CA13E4E00AA0746 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 29F202591CA13E4E00AA0746 /* Assets.xcassets */; };
1414
29F2025D1CA13E4E00AA0746 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 29F2025B1CA13E4E00AA0746 /* LaunchScreen.storyboard */; };
15+
29F202651CA13E6000AA0746 /* DynamicFontSizeHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29F202641CA13E6000AA0746 /* DynamicFontSizeHelper.swift */; };
1516
/* End PBXBuildFile section */
1617

1718
/* Begin PBXFileReference section */
@@ -22,6 +23,7 @@
2223
29F202591CA13E4E00AA0746 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2324
29F2025C1CA13E4E00AA0746 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2425
29F2025E1CA13E4E00AA0746 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
26+
29F202641CA13E6000AA0746 /* DynamicFontSizeHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicFontSizeHelper.swift; sourceTree = "<group>"; };
2527
/* End PBXFileReference section */
2628

2729
/* Begin PBXFrameworksBuildPhase section */
@@ -60,6 +62,7 @@
6062
29F202591CA13E4E00AA0746 /* Assets.xcassets */,
6163
29F2025B1CA13E4E00AA0746 /* LaunchScreen.storyboard */,
6264
29F2025E1CA13E4E00AA0746 /* Info.plist */,
65+
29F202641CA13E6000AA0746 /* DynamicFontSizeHelper.swift */,
6366
);
6467
path = DynamicFontSizeExample;
6568
sourceTree = "<group>";
@@ -137,6 +140,7 @@
137140
files = (
138141
29F202551CA13E4E00AA0746 /* ViewController.swift in Sources */,
139142
29F202531CA13E4E00AA0746 /* AppDelegate.swift in Sources */,
143+
29F202651CA13E6000AA0746 /* DynamicFontSizeHelper.swift in Sources */,
140144
);
141145
runOnlyForDeploymentPostprocessing = 0;
142146
};

DynamicFontSizeExample.xcodeproj/xcuserdata/owenwj.xcuserdatad/xcschemes/DynamicFontSizeExample.xcscheme

+45
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "29F2024E1CA13E4E00AA0746"
18+
BuildableName = "DynamicFontSizeExample.app"
19+
BlueprintName = "DynamicFontSizeExample"
20+
ReferencedContainer = "container:DynamicFontSizeExample.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
824
</BuildAction>
925
<TestAction
1026
buildConfiguration = "Debug"
@@ -13,6 +29,15 @@
1329
shouldUseLaunchSchemeArgsEnv = "YES">
1430
<Testables>
1531
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "29F2024E1CA13E4E00AA0746"
36+
BuildableName = "DynamicFontSizeExample.app"
37+
BlueprintName = "DynamicFontSizeExample"
38+
ReferencedContainer = "container:DynamicFontSizeExample.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
1641
<AdditionalOptions>
1742
</AdditionalOptions>
1843
</TestAction>
@@ -26,6 +51,16 @@
2651
debugDocumentVersioning = "YES"
2752
debugServiceExtension = "internal"
2853
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "29F2024E1CA13E4E00AA0746"
59+
BuildableName = "DynamicFontSizeExample.app"
60+
BlueprintName = "DynamicFontSizeExample"
61+
ReferencedContainer = "container:DynamicFontSizeExample.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
2964
<AdditionalOptions>
3065
</AdditionalOptions>
3166
</LaunchAction>
@@ -35,6 +70,16 @@
3570
savedToolIdentifier = ""
3671
useCustomWorkingDirectory = "NO"
3772
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "29F2024E1CA13E4E00AA0746"
78+
BuildableName = "DynamicFontSizeExample.app"
79+
BlueprintName = "DynamicFontSizeExample"
80+
ReferencedContainer = "container:DynamicFontSizeExample.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
3883
</ProfileAction>
3984
<AnalyzeAction
4085
buildConfiguration = "Debug">
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,124 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
6+
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
57
</dependencies>
68
<scenes>
79
<!--View Controller-->
810
<scene sceneID="tne-QT-ifu">
911
<objects>
10-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
12+
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="DynamicFontSizeExample" customModuleProvider="target" sceneMemberID="viewController">
1113
<layoutGuides>
1214
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
1315
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
1416
</layoutGuides>
1517
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
1618
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
1719
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20+
<subviews>
21+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="固定大小的标签" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="knO-8g-EiI">
22+
<rect key="frame" x="20" y="117" width="120" height="36"/>
23+
<constraints>
24+
<constraint firstAttribute="height" constant="36" id="0jy-mj-sJ7"/>
25+
</constraints>
26+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
27+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
28+
<nil key="highlightedColor"/>
29+
</label>
30+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dynamic size label with system font" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SEa-ev-GCJ">
31+
<rect key="frame" x="20" y="178" width="318" height="36"/>
32+
<constraints>
33+
<constraint firstAttribute="height" constant="36" id="UyC-kH-NjG"/>
34+
</constraints>
35+
<fontDescription key="fontDescription" type="system" pointSize="20"/>
36+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
37+
<nil key="highlightedColor"/>
38+
<userDefinedRuntimeAttributes>
39+
<userDefinedRuntimeAttribute type="number" keyPath="registerForSizeChangeWithDefaultFontSize">
40+
<real key="value" value="20"/>
41+
</userDefinedRuntimeAttribute>
42+
</userDefinedRuntimeAttributes>
43+
</label>
44+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="dynamic size label with custom font" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gMX-hK-ofN">
45+
<rect key="frame" x="20" y="316" width="158" height="36"/>
46+
<constraints>
47+
<constraint firstAttribute="height" constant="36" id="KKc-wg-F2T"/>
48+
</constraints>
49+
<fontDescription key="fontDescription" name="Noteworthy-Light" family="Noteworthy" pointSize="12"/>
50+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
51+
<nil key="highlightedColor"/>
52+
<userDefinedRuntimeAttributes>
53+
<userDefinedRuntimeAttribute type="number" keyPath="registerForSizeChangeWithDefaultFontSize">
54+
<real key="value" value="12"/>
55+
</userDefinedRuntimeAttribute>
56+
</userDefinedRuntimeAttributes>
57+
</label>
58+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="动态大小使用自定义字体的标签" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QkD-Uj-8VM">
59+
<rect key="frame" x="20" y="399" width="168" height="12"/>
60+
<fontDescription key="fontDescription" name="HiraMinProN-W6" family="Hiragino Mincho ProN" pointSize="12"/>
61+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
62+
<nil key="highlightedColor"/>
63+
<userDefinedRuntimeAttributes>
64+
<userDefinedRuntimeAttribute type="number" keyPath="registerForSizeChangeWithDefaultFontSize">
65+
<real key="value" value="12"/>
66+
</userDefinedRuntimeAttribute>
67+
</userDefinedRuntimeAttributes>
68+
</label>
69+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="动态大小使用系统字体的标签" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D0B-Oq-CjA">
70+
<rect key="frame" x="20" y="243" width="318" height="36"/>
71+
<constraints>
72+
<constraint firstAttribute="height" constant="36" id="dMt-Vs-Ev8"/>
73+
</constraints>
74+
<fontDescription key="fontDescription" type="system" pointSize="20"/>
75+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
76+
<nil key="highlightedColor"/>
77+
<userDefinedRuntimeAttributes>
78+
<userDefinedRuntimeAttribute type="number" keyPath="registerForSizeChangeWithDefaultFontSize">
79+
<real key="value" value="20"/>
80+
</userDefinedRuntimeAttribute>
81+
</userDefinedRuntimeAttributes>
82+
</label>
83+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="static size label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6T7-G2-mt2">
84+
<rect key="frame" x="20" y="54" width="120" height="36"/>
85+
<constraints>
86+
<constraint firstAttribute="height" constant="36" id="0wx-wI-mZp"/>
87+
<constraint firstAttribute="width" constant="120" id="9f6-vO-uxu"/>
88+
</constraints>
89+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
90+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
91+
<nil key="highlightedColor"/>
92+
</label>
93+
</subviews>
1894
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
95+
<constraints>
96+
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="QkD-Uj-8VM" secondAttribute="bottom" constant="165" id="Hog-mf-X1c"/>
97+
<constraint firstItem="gMX-hK-ofN" firstAttribute="top" secondItem="D0B-Oq-CjA" secondAttribute="bottom" constant="37" id="Ken-7W-KX3"/>
98+
<constraint firstItem="QkD-Uj-8VM" firstAttribute="top" secondItem="gMX-hK-ofN" secondAttribute="bottom" constant="47" id="L08-IC-Vzj"/>
99+
<constraint firstItem="SEa-ev-GCJ" firstAttribute="top" secondItem="knO-8g-EiI" secondAttribute="bottom" constant="25" id="P1v-bE-Yfa"/>
100+
<constraint firstItem="knO-8g-EiI" firstAttribute="top" secondItem="6T7-G2-mt2" secondAttribute="bottom" constant="27" id="RIS-Hb-HCq"/>
101+
<constraint firstItem="gMX-hK-ofN" firstAttribute="leading" secondItem="QkD-Uj-8VM" secondAttribute="leading" id="WSG-ro-weu"/>
102+
<constraint firstItem="6T7-G2-mt2" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="34" id="WcV-af-vSz"/>
103+
<constraint firstItem="6T7-G2-mt2" firstAttribute="trailing" secondItem="knO-8g-EiI" secondAttribute="trailing" id="Yqb-3O-zLP"/>
104+
<constraint firstItem="6T7-G2-mt2" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leadingMargin" id="ZrH-0U-hzM"/>
105+
<constraint firstItem="6T7-G2-mt2" firstAttribute="leading" secondItem="knO-8g-EiI" secondAttribute="leading" id="b4p-HS-DgY"/>
106+
<constraint firstItem="D0B-Oq-CjA" firstAttribute="leading" secondItem="gMX-hK-ofN" secondAttribute="leading" id="ech-XN-MRa"/>
107+
<constraint firstItem="knO-8g-EiI" firstAttribute="leading" secondItem="SEa-ev-GCJ" secondAttribute="leading" id="qLn-Kw-jCy"/>
108+
<constraint firstItem="D0B-Oq-CjA" firstAttribute="top" secondItem="SEa-ev-GCJ" secondAttribute="bottom" constant="29" id="sQz-v0-h8j"/>
109+
<constraint firstItem="SEa-ev-GCJ" firstAttribute="trailing" secondItem="D0B-Oq-CjA" secondAttribute="trailing" id="wxd-cg-VhJ"/>
110+
<constraint firstItem="SEa-ev-GCJ" firstAttribute="leading" secondItem="D0B-Oq-CjA" secondAttribute="leading" id="y63-IE-HyK"/>
111+
</constraints>
112+
<variation key="default">
113+
<mask key="constraints">
114+
<exclude reference="Hog-mf-X1c"/>
115+
</mask>
116+
</variation>
19117
</view>
20118
</viewController>
21119
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
22120
</objects>
121+
<point key="canvasLocation" x="340" y="387"/>
23122
</scene>
24123
</scenes>
25124
</document>

0 commit comments

Comments
 (0)