Skip to content

Commit 4a5c40f

Browse files
committed
compensate for broken dynamic sizing; add tracking example; revise text field and keyboard example again
1 parent ae2c597 commit 4a5c40f

File tree

19 files changed

+737
-39
lines changed

19 files changed

+737
-39
lines changed

bk2ch10p498fontDescriptor/ch23p670font1dynamicType/ViewController.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ class ViewController : UIViewController {
3636
.preferredFontDescriptor(withTextStyle:.body)
3737
.withDesign(.serif)!
3838
let emphasis = body.withSymbolicTraits(.traitItalic)!
39-
let fbody = UIFont(descriptor: body, size: 0)
40-
let femphasis = UIFont(descriptor: emphasis, size: 0)
39+
var fbody = UIFont(descriptor: body, size: 0)
40+
// work around lack of dynamism; this should not be necessary
41+
fbody = UIFontMetrics(forTextStyle: .body).scaledFont(for: fbody)
42+
var femphasis = UIFont(descriptor: emphasis, size: 0)
43+
// work around lack of dynamism; this should not be necessary
44+
femphasis = UIFontMetrics(forTextStyle: .body).scaledFont(for: femphasis)
4145

4246
let s = self.lab.text!
4347
let mas = NSMutableAttributedString(string: s, attributes: [.font:fbody])
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 50;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
81B1D93924D98A09007CE312 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81B1D93824D98A09007CE312 /* AppDelegate.swift */; };
11+
81B1D93B24D98A09007CE312 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81B1D93A24D98A09007CE312 /* SceneDelegate.swift */; };
12+
81B1D93D24D98A09007CE312 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 81B1D93C24D98A09007CE312 /* ViewController.swift */; };
13+
81B1D94024D98A09007CE312 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81B1D93E24D98A09007CE312 /* Main.storyboard */; };
14+
81B1D94224D98A0A007CE312 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 81B1D94124D98A0A007CE312 /* Assets.xcassets */; };
15+
81B1D94524D98A0A007CE312 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81B1D94324D98A0A007CE312 /* LaunchScreen.storyboard */; };
16+
/* End PBXBuildFile section */
17+
18+
/* Begin PBXFileReference section */
19+
81B1D93524D98A09007CE312 /* Tracking.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tracking.app; sourceTree = BUILT_PRODUCTS_DIR; };
20+
81B1D93824D98A09007CE312 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
21+
81B1D93A24D98A09007CE312 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
22+
81B1D93C24D98A09007CE312 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
23+
81B1D93F24D98A09007CE312 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
24+
81B1D94124D98A0A007CE312 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
25+
81B1D94424D98A0A007CE312 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
26+
81B1D94624D98A0A007CE312 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
27+
/* End PBXFileReference section */
28+
29+
/* Begin PBXFrameworksBuildPhase section */
30+
81B1D93224D98A09007CE312 /* Frameworks */ = {
31+
isa = PBXFrameworksBuildPhase;
32+
buildActionMask = 2147483647;
33+
files = (
34+
);
35+
runOnlyForDeploymentPostprocessing = 0;
36+
};
37+
/* End PBXFrameworksBuildPhase section */
38+
39+
/* Begin PBXGroup section */
40+
81B1D92C24D98A09007CE312 = {
41+
isa = PBXGroup;
42+
children = (
43+
81B1D93724D98A09007CE312 /* Tracking */,
44+
81B1D93624D98A09007CE312 /* Products */,
45+
);
46+
sourceTree = "<group>";
47+
};
48+
81B1D93624D98A09007CE312 /* Products */ = {
49+
isa = PBXGroup;
50+
children = (
51+
81B1D93524D98A09007CE312 /* Tracking.app */,
52+
);
53+
name = Products;
54+
sourceTree = "<group>";
55+
};
56+
81B1D93724D98A09007CE312 /* Tracking */ = {
57+
isa = PBXGroup;
58+
children = (
59+
81B1D93824D98A09007CE312 /* AppDelegate.swift */,
60+
81B1D93A24D98A09007CE312 /* SceneDelegate.swift */,
61+
81B1D93C24D98A09007CE312 /* ViewController.swift */,
62+
81B1D93E24D98A09007CE312 /* Main.storyboard */,
63+
81B1D94124D98A0A007CE312 /* Assets.xcassets */,
64+
81B1D94324D98A0A007CE312 /* LaunchScreen.storyboard */,
65+
81B1D94624D98A0A007CE312 /* Info.plist */,
66+
);
67+
path = Tracking;
68+
sourceTree = "<group>";
69+
};
70+
/* End PBXGroup section */
71+
72+
/* Begin PBXNativeTarget section */
73+
81B1D93424D98A09007CE312 /* Tracking */ = {
74+
isa = PBXNativeTarget;
75+
buildConfigurationList = 81B1D94924D98A0A007CE312 /* Build configuration list for PBXNativeTarget "Tracking" */;
76+
buildPhases = (
77+
81B1D93124D98A09007CE312 /* Sources */,
78+
81B1D93224D98A09007CE312 /* Frameworks */,
79+
81B1D93324D98A09007CE312 /* Resources */,
80+
);
81+
buildRules = (
82+
);
83+
dependencies = (
84+
);
85+
name = Tracking;
86+
productName = Tracking;
87+
productReference = 81B1D93524D98A09007CE312 /* Tracking.app */;
88+
productType = "com.apple.product-type.application";
89+
};
90+
/* End PBXNativeTarget section */
91+
92+
/* Begin PBXProject section */
93+
81B1D92D24D98A09007CE312 /* Project object */ = {
94+
isa = PBXProject;
95+
attributes = {
96+
LastSwiftUpdateCheck = 1200;
97+
LastUpgradeCheck = 1200;
98+
TargetAttributes = {
99+
81B1D93424D98A09007CE312 = {
100+
CreatedOnToolsVersion = 12.0;
101+
};
102+
};
103+
};
104+
buildConfigurationList = 81B1D93024D98A09007CE312 /* Build configuration list for PBXProject "Tracking" */;
105+
compatibilityVersion = "Xcode 9.3";
106+
developmentRegion = en;
107+
hasScannedForEncodings = 0;
108+
knownRegions = (
109+
en,
110+
Base,
111+
);
112+
mainGroup = 81B1D92C24D98A09007CE312;
113+
productRefGroup = 81B1D93624D98A09007CE312 /* Products */;
114+
projectDirPath = "";
115+
projectRoot = "";
116+
targets = (
117+
81B1D93424D98A09007CE312 /* Tracking */,
118+
);
119+
};
120+
/* End PBXProject section */
121+
122+
/* Begin PBXResourcesBuildPhase section */
123+
81B1D93324D98A09007CE312 /* Resources */ = {
124+
isa = PBXResourcesBuildPhase;
125+
buildActionMask = 2147483647;
126+
files = (
127+
81B1D94524D98A0A007CE312 /* LaunchScreen.storyboard in Resources */,
128+
81B1D94224D98A0A007CE312 /* Assets.xcassets in Resources */,
129+
81B1D94024D98A09007CE312 /* Main.storyboard in Resources */,
130+
);
131+
runOnlyForDeploymentPostprocessing = 0;
132+
};
133+
/* End PBXResourcesBuildPhase section */
134+
135+
/* Begin PBXSourcesBuildPhase section */
136+
81B1D93124D98A09007CE312 /* Sources */ = {
137+
isa = PBXSourcesBuildPhase;
138+
buildActionMask = 2147483647;
139+
files = (
140+
81B1D93D24D98A09007CE312 /* ViewController.swift in Sources */,
141+
81B1D93924D98A09007CE312 /* AppDelegate.swift in Sources */,
142+
81B1D93B24D98A09007CE312 /* SceneDelegate.swift in Sources */,
143+
);
144+
runOnlyForDeploymentPostprocessing = 0;
145+
};
146+
/* End PBXSourcesBuildPhase section */
147+
148+
/* Begin PBXVariantGroup section */
149+
81B1D93E24D98A09007CE312 /* Main.storyboard */ = {
150+
isa = PBXVariantGroup;
151+
children = (
152+
81B1D93F24D98A09007CE312 /* Base */,
153+
);
154+
name = Main.storyboard;
155+
sourceTree = "<group>";
156+
};
157+
81B1D94324D98A0A007CE312 /* LaunchScreen.storyboard */ = {
158+
isa = PBXVariantGroup;
159+
children = (
160+
81B1D94424D98A0A007CE312 /* Base */,
161+
);
162+
name = LaunchScreen.storyboard;
163+
sourceTree = "<group>";
164+
};
165+
/* End PBXVariantGroup section */
166+
167+
/* Begin XCBuildConfiguration section */
168+
81B1D94724D98A0A007CE312 /* Debug */ = {
169+
isa = XCBuildConfiguration;
170+
buildSettings = {
171+
ALWAYS_SEARCH_USER_PATHS = NO;
172+
CLANG_ANALYZER_NONNULL = YES;
173+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
174+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
175+
CLANG_CXX_LIBRARY = "libc++";
176+
CLANG_ENABLE_MODULES = YES;
177+
CLANG_ENABLE_OBJC_ARC = YES;
178+
CLANG_ENABLE_OBJC_WEAK = YES;
179+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
180+
CLANG_WARN_BOOL_CONVERSION = YES;
181+
CLANG_WARN_COMMA = YES;
182+
CLANG_WARN_CONSTANT_CONVERSION = YES;
183+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
184+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
185+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
186+
CLANG_WARN_EMPTY_BODY = YES;
187+
CLANG_WARN_ENUM_CONVERSION = YES;
188+
CLANG_WARN_INFINITE_RECURSION = YES;
189+
CLANG_WARN_INT_CONVERSION = YES;
190+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
191+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
192+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
193+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
194+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
195+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
196+
CLANG_WARN_STRICT_PROTOTYPES = YES;
197+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
198+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
199+
CLANG_WARN_UNREACHABLE_CODE = YES;
200+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201+
COPY_PHASE_STRIP = NO;
202+
DEBUG_INFORMATION_FORMAT = dwarf;
203+
ENABLE_STRICT_OBJC_MSGSEND = YES;
204+
ENABLE_TESTABILITY = YES;
205+
GCC_C_LANGUAGE_STANDARD = gnu11;
206+
GCC_DYNAMIC_NO_PIC = NO;
207+
GCC_NO_COMMON_BLOCKS = YES;
208+
GCC_OPTIMIZATION_LEVEL = 0;
209+
GCC_PREPROCESSOR_DEFINITIONS = (
210+
"DEBUG=1",
211+
"$(inherited)",
212+
);
213+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
214+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
215+
GCC_WARN_UNDECLARED_SELECTOR = YES;
216+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
217+
GCC_WARN_UNUSED_FUNCTION = YES;
218+
GCC_WARN_UNUSED_VARIABLE = YES;
219+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
220+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
221+
MTL_FAST_MATH = YES;
222+
ONLY_ACTIVE_ARCH = YES;
223+
SDKROOT = iphoneos;
224+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
225+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
226+
};
227+
name = Debug;
228+
};
229+
81B1D94824D98A0A007CE312 /* Release */ = {
230+
isa = XCBuildConfiguration;
231+
buildSettings = {
232+
ALWAYS_SEARCH_USER_PATHS = NO;
233+
CLANG_ANALYZER_NONNULL = YES;
234+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
235+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
236+
CLANG_CXX_LIBRARY = "libc++";
237+
CLANG_ENABLE_MODULES = YES;
238+
CLANG_ENABLE_OBJC_ARC = YES;
239+
CLANG_ENABLE_OBJC_WEAK = YES;
240+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
241+
CLANG_WARN_BOOL_CONVERSION = YES;
242+
CLANG_WARN_COMMA = YES;
243+
CLANG_WARN_CONSTANT_CONVERSION = YES;
244+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
245+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
246+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
247+
CLANG_WARN_EMPTY_BODY = YES;
248+
CLANG_WARN_ENUM_CONVERSION = YES;
249+
CLANG_WARN_INFINITE_RECURSION = YES;
250+
CLANG_WARN_INT_CONVERSION = YES;
251+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
252+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
253+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
254+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
255+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
256+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
257+
CLANG_WARN_STRICT_PROTOTYPES = YES;
258+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
259+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
260+
CLANG_WARN_UNREACHABLE_CODE = YES;
261+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
262+
COPY_PHASE_STRIP = NO;
263+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
264+
ENABLE_NS_ASSERTIONS = NO;
265+
ENABLE_STRICT_OBJC_MSGSEND = YES;
266+
GCC_C_LANGUAGE_STANDARD = gnu11;
267+
GCC_NO_COMMON_BLOCKS = YES;
268+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
269+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
270+
GCC_WARN_UNDECLARED_SELECTOR = YES;
271+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
272+
GCC_WARN_UNUSED_FUNCTION = YES;
273+
GCC_WARN_UNUSED_VARIABLE = YES;
274+
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
275+
MTL_ENABLE_DEBUG_INFO = NO;
276+
MTL_FAST_MATH = YES;
277+
SDKROOT = iphoneos;
278+
SWIFT_COMPILATION_MODE = wholemodule;
279+
SWIFT_OPTIMIZATION_LEVEL = "-O";
280+
VALIDATE_PRODUCT = YES;
281+
};
282+
name = Release;
283+
};
284+
81B1D94A24D98A0A007CE312 /* Debug */ = {
285+
isa = XCBuildConfiguration;
286+
buildSettings = {
287+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
288+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
289+
CODE_SIGN_STYLE = Automatic;
290+
DEVELOPMENT_TEAM = W3LHX5RGV2;
291+
INFOPLIST_FILE = Tracking/Info.plist;
292+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
293+
LD_RUNPATH_SEARCH_PATHS = (
294+
"$(inherited)",
295+
"@executable_path/Frameworks",
296+
);
297+
PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.Tracking;
298+
PRODUCT_NAME = "$(TARGET_NAME)";
299+
SWIFT_VERSION = 5.0;
300+
TARGETED_DEVICE_FAMILY = "1,2";
301+
};
302+
name = Debug;
303+
};
304+
81B1D94B24D98A0A007CE312 /* Release */ = {
305+
isa = XCBuildConfiguration;
306+
buildSettings = {
307+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
308+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
309+
CODE_SIGN_STYLE = Automatic;
310+
DEVELOPMENT_TEAM = W3LHX5RGV2;
311+
INFOPLIST_FILE = Tracking/Info.plist;
312+
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
313+
LD_RUNPATH_SEARCH_PATHS = (
314+
"$(inherited)",
315+
"@executable_path/Frameworks",
316+
);
317+
PRODUCT_BUNDLE_IDENTIFIER = com.neuburg.matt.Tracking;
318+
PRODUCT_NAME = "$(TARGET_NAME)";
319+
SWIFT_VERSION = 5.0;
320+
TARGETED_DEVICE_FAMILY = "1,2";
321+
};
322+
name = Release;
323+
};
324+
/* End XCBuildConfiguration section */
325+
326+
/* Begin XCConfigurationList section */
327+
81B1D93024D98A09007CE312 /* Build configuration list for PBXProject "Tracking" */ = {
328+
isa = XCConfigurationList;
329+
buildConfigurations = (
330+
81B1D94724D98A0A007CE312 /* Debug */,
331+
81B1D94824D98A0A007CE312 /* Release */,
332+
);
333+
defaultConfigurationIsVisible = 0;
334+
defaultConfigurationName = Release;
335+
};
336+
81B1D94924D98A0A007CE312 /* Build configuration list for PBXNativeTarget "Tracking" */ = {
337+
isa = XCConfigurationList;
338+
buildConfigurations = (
339+
81B1D94A24D98A0A007CE312 /* Debug */,
340+
81B1D94B24D98A0A007CE312 /* Release */,
341+
);
342+
defaultConfigurationIsVisible = 0;
343+
defaultConfigurationName = Release;
344+
};
345+
/* End XCConfigurationList section */
346+
};
347+
rootObject = 81B1D92D24D98A09007CE312 /* Project object */;
348+
}

bk2ch10p503Tracking/Tracking.xcodeproj/project.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import UIKit
3+
4+
@main
5+
class AppDelegate: UIResponder, UIApplicationDelegate {
6+
7+
8+
9+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
10+
// Override point for customization after application launch.
11+
return true
12+
}
13+
14+
15+
16+
}
17+

0 commit comments

Comments
 (0)