UIKit User Interface Catalog Par

2017-09-11  本文已影响0人  大地瓜123

本文为大地瓜原创,欢迎知识共享,转载请注明出处。
虽然你不注明出处我也没什么精力和你计较。
作者微信号:christgreenlaw


2017-10-12日更新:
苹果官网删除了本文档,已经找不到这个文档了,好在我还有pdf版,现共享给大家。
链接:http://pan.baidu.com/s/1i5GKG9v 密码:9g6z


正如文档的名字,UIKit中的用户界面目录,其实简单的来讲,这篇文档就是把常见的界面组件列了个目录,大概介绍,而不深入。


Activity Indicators

An activity indicator is a spinning wheel that indicates a task is in the midst of being processed. If an action takes a noticeable and indeterminate amount of time to process—such as a CPU-intensive task or connecting to a network—you should display an activity indicator to give assurance to the user that your app is not stalled or frozen.

Activity Indicator是一个转动的轮子,表示任务正在被处理。如果一个操作花费很多的时间来处理,且需要的时间不确定--比如CPU密集型作业或者连接网络--你就应该显示一个Activity Indicator来告知用户你的app并不是卡住了或死掉了。

Activity Indicators

Purpose. Activity indicators allow users to:
Receive feedback that the system is processing information
//Activity indicators让用户知道“系统正在处理信息”

Implementation. Activity indicators are implemented in the UIActivityIndicatorView class and discussed in the UIActivityIndicatorView Class Reference.
//Activity indicators在UIActivityIndicatorView中实现 and在 UIActivityIndicatorView Class Reference有所讨论。

Configuration. Configure activity indicators in Interface Builder, in the Activity Indicator section of the Attributes Inspector. A few configurations cannot be made through the Attributes Inspector, so you must make them programmatically. You can set other configurations programmatically, too, if you prefer.

//在IB中配置activity indicators,在Attributes Inspector的Activity Indicator部分。有些配置不能通过Attributes Inspector进行配置,所以你必须用代码来配置。如果你喜欢的话,你也可以将其他的配置都用代码来做。


Attributes Inspector

Content of Activity Indicators

An activity indicator is indeterminate, and has no starting or ending values associated with it.

activity indicator是indeterminate的,没有相关的初始值和结束值。

Behavior of Activity Indicators

The Animating (isAnimating) box is unchecked by default; checking it causes the activity indicator to start animating. This is the equivalent of calling the startAnimating method.

Animating (isAnimating) box 默认是不选中的。选中它将会使activity indicator开始动画。这与调用startAnimating 方法是等价的。

Select the Hides When Stopped (hidesWhenStopped) field in the Attributes Inspector for your activity indicator to disappear when the animation ends. When you call the startAnimating and stopAnimating methods, the activity indicator automatically shows and hides onscreen. This way, you won’t have to worry about displaying a stationary activity indicator.

选中Attributes Inspector中Hides When Stopped (hidesWhenStopped) 选项,允许你的activity indicator在动画停止时自动消失。当你调用startAnimating and stopAnimating 方法时,activity indicator将会自动的显示和消失。用这种方式,你不需要担心展示出一个停滞的 activity indicator。

Appearance of Activity Indicators

You can customize the appearance of an activity indicator by setting the properties depicted below.

你可以用以下属性来自定义 activity indicator的外观。

外观
To customize the appearance of all activity indicators in your app, use the appearance proxy (for example, [UIActivityIndicatorView appearance]). For more information about appearance proxies, see Appearance Proxies.

要自定义app中所有 activity indicator的外观,使用外观代理(for example, [UIActivityIndicatorView appearance])。For more information about appearance proxies, see Appearance Proxies.

Style

The Style (activityIndicatorViewStyle) field represents the predefined style of the activity indicator. Use the style to specify one of two default colors: white or gray. You can also select a larger size for your indicator using the “Large White” style option.

Style (activityIndicatorViewStyle) 域展示了activity indicator预定义的Style。用style来指明两种默认颜色之一:白色或灰色。你也可以用“Large White”选项来选择一个更大的尺寸。

The Color (color) field allows you to specify a custom color for your indicator. This property takes precedence over any color set using the Style field. However, if your style is set to Large White, your activity indicator appears a larger size. Make sure your indicator is set to a different style option if you want to use the small indicator.

Color (color)域允许你指明indicator的自定义颜色。这个属性将会覆盖任何Style域所设置的颜色。然而,如果你style选择的是Large White,你的activity indicator将会有更大的尺寸。如果你需要一个小的activity indicator,请确认你的indicator设置为一个不同的style。

Style

Using Auto Layout with Activity Indicators

You can create Auto Layout constraints between an activity indicator and other UI elements.

你可以在activity indicator和其他UI元素之间创建Auto Layout约束。

Typically, activity indicators appear before a label or centered within a view. To align with a label, constrain Bottom Edges and Horizontal Space to the label with the standard value. To center within a view, add the Horizontal Center in Container and Vertical Center in Container constraints.

通常来说,activity indicators在一个label之前显示,或者在view的中心显示。剩下部分看英文吧。都是 Auto Layout的简单问题。

For general information about using Auto Layout with iOS views, see Using Auto Layout with Views.

Making Activity Indicators Accessible

Activity indicators are accessible by default. The default accessibility trait for an activity indicator is User Interaction Enabled.
If you have a label next to your activity indicator that describes the processing task in more detail, you might want to disable its accessibility with the isAccessibilityElement
property so VoiceOver reads the label instead. Otherwise, VoiceOver reads “In progress” while the activity indicator is animating, and “Progress halted” while it is not.
VoiceOver will read only elements that are visible onscreen. If you enable the hidesWhenStopped
property, VoiceOver might abruptly stop speaking when the animation finishes.
For general information about making iOS views accessible, see Making Views Accessible.

Internationalizing Activity Indicators

Activity indicators have no special properties related to internationalization. However, if you use an activity indicator with a label, make sure you provide localized strings for the label.
For more information, see Internationalization and Localization Guide.

Debugging Activity Indicators

When debugging issues with activity indicators, watch for this common pitfall:
Specifying conflicting appearance settings. The color property takes precedence over any color set using the activityIndicatorViewStyle property. However, if your style is set to Large White, your activity indicator appears a larger size with whatever custom color you set. Make sure your indicator is set to a different style option if you want to use the small indicator.

debug时注意这个陷阱:
设置了冲突的外观color属性会覆盖任何 activityIndicatorViewStyle 属性声明的颜色。然而,如果你style选择的是Large White,你的activity indicator将会有更大的尺寸。如果你需要一个小的activity indicator,请确认你的indicator设置为一个不同的style。

Elements Similar to an Activity Indicator

The following element provides similar functionality to an activity indicator:
Progress View. A class that represents a progress bar. Use this class instead of an activity indicator when your task takes a determinate amount of time. For more information, see Progress Views.

以下元素提供了和activity indicator类似的功能:
Progress View。这个类显示一个progress bar。当你的任务使用的时间可确定时,使用progress view。For more information, see Progress Views.

上一篇下一篇

猜你喜欢

热点阅读