Skip to content

Commit ce0d79d

Browse files
committed
翻译至1199
1 parent c74d358 commit ce0d79d

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

subtitles/5. Drawing.srt

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5647,282 +5647,352 @@ we like the fonts big. Then we can hold it all closer and
56475647
1130
56485648
00:58:16,259 --> 00:58:18,993
56495649
see our fonts. Well, the way we do that is we go into our
5650-
来看字了。
5650+
来看字了。我们做到这一点的方式是
5651+
56515652
1131
56525653
00:58:19,062 --> 00:58:22,297
56535654
settings on our phone, and one of the settings under general
5655+
去我们手机的设置里,在通用标签下面
56545656

56555657
1132
56565658
00:58:22,365 --> 00:58:25,433
56575659
there is accessibility, and we can say larger text, and
5660+
有一个辅助功能,在那里我们可以设置更大的字体
56585661

56595662
1133
56605663
00:58:25,502 --> 00:58:27,102
56615664
we move the little slider, and
5665+
我们划一划滑块
56625666

56635667
1134
56645668
00:58:27,170 --> 00:58:29,705
56655669
now all the fonts get bigger in all the apps, but
5670+
就能让所有 app 中的所有字体变大
56665671

56675672
1135
56685673
00:58:29,773 --> 00:58:32,074
56695674
only the apps that play this game right, and
5675+
但也仅限于能正确处理更大字体的 app
56705676

56715677
1136
56725678
00:58:32,142 --> 00:58:35,143
56735679
use preferred fonts. So you wanna be one of those apps,
5680+
它们要用首选字体,那么你就要
56745681

56755682
1137
56765683
00:58:35,212 --> 00:58:37,846
56775684
otherwise, you're gonna lose the older folk from
5685+
让你的 app 也能做到这一点。否则你就会
56785686

56795687
1138
56805688
00:58:37,915 --> 00:58:39,314
56815689
your demographic,
5690+
丢失你的老年用户群体
56825691

56835692
1139
56845693
00:58:39,382 --> 00:58:43,084
56855694
of your people buying your app. So it's important to make
5695+
它们就不会买你的 app 了。所以要确保
56865696

56875697
1140
56885698
00:58:43,153 --> 00:58:46,054
56895699
sure that your UI also works when fonts get bigger and
5700+
当字体变大变小的时候,你的 UI 能够正常工作
56905701

56915702
1141
56925703
00:58:46,122 --> 00:58:50,592
56935704
smaller, and the number one way to do that, auto layout.
5705+
做到这一点的最好的方式是用 auto layout(自动布局)
56945706

56955707
1142
56965708
00:58:50,661 --> 00:58:52,494
56975709
You know that auto layout where you put constraints,
5710+
我们之前使用约束(constrain)的时候就用到了 auto layout
56985711

56995712
1143
57005713
00:58:52,563 --> 00:58:55,697
57015714
pin things to the edges. You wanna use good auto layout so
5715+
我们那时将控件控制在边上。你要正确地使用 auto layout
57025716

57035717
1144
57045718
00:58:55,766 --> 00:58:58,800
57055719
as fonts get bigger, and the text field gets bigger, other
5720+
这样当字体变大的时候,它所在的文字空间也变大了
57065721

57075722
1145
57085723
00:58:58,869 --> 00:59:01,836
57095724
things push out of the way and it uses the screen real estate
5725+
其他的东西就被往旁边推了,并且有效地
57105726

57115727
1146
57125728
00:59:01,905 --> 00:59:03,805
57135729
properly. So you've only seen a little bit of auto layout.
5730+
使用屏幕上的空间。你们还没有见过很多 auto layout 的例子
57145731

57155732
1147
57165733
00:59:03,874 --> 00:59:06,608
57175734
I'm gonna show you more auto layout at start of Wednesday's
5735+
在周三的课程的开始,我会向你们展示更多的
57185736

57195737
1148
57205738
00:59:06,676 --> 00:59:07,942
57215739
lecture. You're gonna see more and
5740+
auto layout 的例子。之后
57225741

57235742
1149
57245743
00:59:08,011 --> 00:59:09,444
57255744
more as the quarter goes by, but
5745+
你们会见得越来越多
57265746

57275747
1150
57285748
00:59:09,512 --> 00:59:13,047
57295749
that's a good way to make it work. Now what if you
5750+
这是让字体大小正确工作的很好的方式,如果
57305751

57315752
1151
57325753
00:59:13,116 --> 00:59:17,418
57335754
either wanna use some other font, some special font that's
5755+
你既想要用一些其他类型的字体,其他特殊的字体
57345756

57355757
1152
57365758
00:59:17,487 --> 00:59:22,057
57375759
something that's maybe part of your marketing or whatever, or
5760+
比如说是你的用于宣传的字体或者其他什么
57385761

57395762
1153
57405763
00:59:22,126 --> 00:59:25,293
57415764
you want it to be bigger, or smaller I guess,
5765+
而你想让它特定的首选字体的
57425766

57435767
1154
57445768
00:59:25,362 --> 00:59:29,064
57455769
than the standard size font that comes with a certain
5770+
标准大小更大或者更小
57465771

57475772
1155
57485773
00:59:29,133 --> 00:59:32,467
57495774
prefered font. Okay, well, UIFont does have a way to
5775+
UIFont 的确有一种
57505776

57515777
1156
57525778
00:59:32,536 --> 00:59:35,837
57535779
create a font by name like if you want Helvetica 36 point,
5780+
用名字来创建字体的方式。比如说你想要大小是 36,字体是 Helvetica
57545781

57555782
1157
57565783
00:59:35,906 --> 00:59:39,841
57575784
you can say UIFont(name: "Helvetica", size: 36.0), and
5785+
你只用写 UIFont(name: "Helvetica", size: 36.0)
57585786

57595787
1158
57605788
00:59:39,909 --> 00:59:42,711
57615789
there's also a class called UIFontDescriptor.
5790+
还有一个类叫做 UIFontDescriptor
57625791

57635792
1159
57645793
00:59:42,780 --> 00:59:44,579
57655794
Has a lot of cool ways where you can take a font and
5795+
它有很多类似于接受一个字体
57665796

57675797
1160
57685798
00:59:44,648 --> 00:59:46,380
57695799
say give me the Bold version of this,
5800+
并返回这个字体的粗体
57705801

57715802
1161
57725803
00:59:46,449 --> 00:59:49,084
57735804
give me the Italic version, okay all of that stuff. So
5805+
或者斜体的函数。类似的那些函数
57745806

57755807
1162
57765808
00:59:49,152 --> 00:59:51,787
57775809
you can get your font this way. But if you do your fonts
5810+
所以你可以以这样的方式获得你的字体。但如果你是
57785811

57795812
1163
57805813
00:59:51,855 --> 00:59:55,190
57815814
this way, you still want, when I go into my setting and
5815+
这样取得的字体,当我进入我的设置
57825816

57835817
1164
57845818
00:59:55,259 --> 00:59:58,427
57855819
make my font bigger, you want your font to get bigger, and
5820+
并让我的字体变大时,你也想让这些字体变大
57865821

57875822
1165
57885823
00:59:58,495 --> 01:00:02,330
57895824
look what font size this is, 36. It's fixed.
5825+
来看看这个字体的大小是多少?36,这是固定的
57905826

57915827
1166
57925828
01:00:02,399 --> 01:00:04,899
57935829
So I need to somehow scale this font up
5830+
所以当用户将它们的字体调大的时候
57945831

57955832
1167
57965833
01:00:04,968 --> 01:00:08,069
57975834
if the user has put their slider to bigger, and
5835+
我要想办法把这个字体变大
57985836

57995837
1168
58005838
01:00:08,137 --> 01:00:11,540
58015839
the way you do that is with UIFontMetrics. So you create
5840+
做到这一点的方法使用 UIFontMetrics
58025841

58035842
1169
58045843
01:00:11,608 --> 01:00:15,710
58055844
a UIFontMetrics object for the text style body, footnote,
5845+
你要为你的文字的字体创建一个
58065846

58075847
1170
58085848
01:00:15,779 --> 01:00:19,080
58095849
caption, whatever, and then it has very cool method called
5850+
UIFontMetrics 对象,而它有一个叫做 scaledFont
58105851

58115852
1171
58125853
01:00:19,149 --> 01:00:22,283
58135854
scaledFont, and you give it a font, like Helvetica 36,
5855+
的很酷的函数你给它传递一个字体,比如说 36 大小的 Helvetica
58145856

58155857
1172
58165858
01:00:22,352 --> 01:00:27,121
58175859
and it will give you back a new font, Helvetica 42, maybe.
5860+
而它会返回给你一个新的字体,可能是 42 大小的 Helvetica
58185861

58195862
1173
58205863
01:00:27,190 --> 01:00:31,492
58215864
It's scaled based on what the user said. Okay, don't skip
5865+
它以用户设定的字体大小为基准缩放字体
58225866

58235867
1174
58245868
01:00:31,561 --> 01:00:34,528
58255869
this step, otherwise, if you use a custom font,
5870+
不要跳过这一步,否则当你在用自定义字体的时候
58265871

58275872
1175
58285873
01:00:34,597 --> 01:00:38,333
58295874
when people move that slider, your app's not gonna work, and
5875+
当用户调整字体大小,你的 app 就不能正常运作了
58305876

58315877
1176
58325878
01:00:38,402 --> 01:00:40,935
58335879
people are gonna be like, I hate that app.
5880+
人们就会讨厌你的 app
58345881

58355882
1177
58365883
01:00:41,004 --> 01:00:45,373
58375884
I can't see any of the text and it's too small.
5885+
因为它们看不清这些小的字
58385886

58395887
1178
58405888
01:00:45,442 --> 01:00:48,776
58415889
There are also system fonts. We use those so far in our
5890+
还有一类字体是系统字体,我们在我们的
58425891

58435892
1179
58445893
01:00:48,845 --> 01:00:51,780
58455894
concentration demo. That's only for things like button
5895+
Concentration 示例中用过它们了。它们只是用于
58465896

58475897
1180
58485898
01:00:51,848 --> 01:00:54,616
58495899
titles, and stuff like that, that's not for user content,
5900+
类似按钮上的文字或者其它类似的东西的。它们不是用于
58505901

58515902
1181
58525903
01:00:54,685 --> 01:00:57,118
58535904
stuff that the user has generated, or requested, or
5905+
展示给用户或者用户生成的内容的
58545906

58555907
1182
58565908
01:00:57,187 --> 01:00:59,454
58575909
something like that. Thos are preferred fonts.
5910+
那些是首选字体
58585911

58595912
1183
58605913
01:00:59,523 --> 01:01:03,491
58615914
System fonts are just like buttons, things like that.
5915+
系统字体只是用于按钮之类的东西
58625916

58635917
1184
58645918
01:01:03,560 --> 01:01:05,826
58655919
What about images? We know how to draw lines and arcs.
5920+
那么我们该如何画图片呢?我们已经知道如何画直线和弧
58665921

58675922
1185
58685923
01:01:05,895 --> 01:01:06,928
58695924
We know how to draw text.
5925+
知道该如何画文字
58705926

58715927
1186
58725928
01:01:06,997 --> 01:01:11,032
58735929
What about drawing images? Just like UILabel for text,
5930+
那么如何画图片呢,就像 UILabel 是用来装文字的
58745931

58755932
1187
58765933
01:01:11,101 --> 01:01:13,868
58775934
there's another one called UIImageView,
5935+
我们有 UIImageView
58785936

58795937
1188
58805938
01:01:13,937 --> 01:01:17,839
58815939
which lets you add an image as a subview. So you could use
5940+
它可以让你将一个图片添加为它的子视图
58825941

58835942
1189
58845943
01:01:17,907 --> 01:01:20,474
58855944
that to draw an image in your view if you want it,
5945+
所以如果你需要的话,你可以用它来画图片
58865946

58875947
1190
58885948
01:01:20,543 --> 01:01:23,711
58895949
just do it as a subview. But if you wanna draw an image
5950+
只需要将图片添加进子视图。但如果你想在你的
58905951

58915952
1191
58925953
01:01:23,780 --> 01:01:26,481
58935954
in your drawRect, you can do that too.
5955+
draw(rect)
58945956

58955957
1192
58965958
01:01:26,549 --> 01:01:29,784
58975959
You need a UIImage object. A UIImage represents an image,
5960+
你需要一个 UIImage 对象,一个 UIImage 代表着一张图片
58985961

58995962
1193
59005963
01:01:29,852 --> 01:01:33,287
59015964
jpg, gif, whatever kind of image, it represents an image.
5965+
代表着 jpg,git 之类任意类型的图片
59025966

59035967
1194
59045968
01:01:33,356 --> 01:01:36,457
59055969
Now, how do you get an image? There's a bunch of ways to do
5970+
那么你如何获取一张图片呢?我们有很多方式来做
59065971

59075972
1195
59085973
01:01:36,526 --> 01:01:40,562
59095974
it. One way is to drag the jpg file, or whatever, into that
5975+
其中一种就是将一张图片文件
59105976

59115977
1196
59125978
01:01:40,630 --> 01:01:44,132
59135979
Assets.xcassets file. Remember when we're doing our demo,
5980+
拖进那个 Assets.xcassets 文件中,还记得我们做我们的示例程序
59145981

59155982
1197
59165983
01:01:44,201 --> 01:01:46,300
59175984
and I put some things off in supporting files?
5985+
的时候,我将一些文件拖进那个 supporting files 文件夹吗
59185986

59195987
1198
59205988
01:01:46,369 --> 01:01:48,937
59215989
One of the things I threw in there was the place where
5990+
我拖进去的其中一文件
59225991

59235992
1199
59245993
01:01:49,006 --> 01:01:51,539
59255994
the app icon was. Well, you can drag other images in
5995+
就是装有程序图标的文件,你也可以将其他图片拖进那里
59265996

59275997
1200
59285998
01:01:51,607 --> 01:01:54,308

0 commit comments

Comments
 (0)