创建: 2018/04/21
完成: 2018/04/25
更新: 2018/09/24 补充UIActivityIndicatorView的显示和隐藏方法
UIButton |
设定项目 |
项目名 | 方法名/属性名 | | Title | setTitle | 设置按钮上的标题 | Text Color | setTitleColor | 设置标题颜色 | Image | setImage | 设置取代标题的图片 | Background (Image) | setBackgroundImage | 设置背景图片 | Alignment(Horizontal) | contentHorizontalAlignment | 设置标题的水平位置 | Alignment(Vertical) | contentVerticalAlignment | 设置标题的竖直位置 | Enabled | isEnabled | 是否可点击 | Hidden | isHidden | 是否隐藏 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景颜色 | Action | addTarget | 指定点击后的处理 | | | |
|
action | 三要素
事件(Event) | 操作的种类 | 对象(UI自身, 方法的sender) | 被操作的对象 | 受体(方法) | 进行处理的函数 |
|
代码创建 | 不用 |
| |
| |
| |
| |
| |
UILabel |
设定项目 |
项目名 | 属性/方法 | | Text | text | UILabel的文字 | Color | textColor | 文字颜色 | Font | font | 文字的字体 | Lines | numberOfLines | 行数 设为0则自动判断 | Alignment | textAlignment | 文字的位置 (靠左, 靠右, 居中) | Line Break | lineBreakMode | 改行方式 被省略部分表示为 ...
Truncate Tail | 省略末尾 | Truncate Middle | 省略中间 | Truncate Head | 省略开头 | Clip | 直接不表示 | Character Wrap | | | | | |
| Hidden | isHidden | 是否隐藏 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 |
|
storybord上的一些操作 | ● 换行: option+return |
| |
| |
| |
| |
| |
| |
UITextField |
| 用来输入一行文字 |
设定项目 | 更高级的用法在TextKit
项目名 | 属性/方法 | | Text | text | 输入的文字 | Color | textColor | 文字颜色 | Font | font | 文字字体 | Alignment | textAlignment | 文字位置 | Editable | isEditable | 是否可以编辑 | Selectable | | 是否可选 | Data Detectors | dataDectectorTypes | 侦测特定内容生成链接 | Text Input Traits | | | Indicators | indicatorStyle | 滚动条的样式 | Scrolling Enabled | isScrollEnabled | 是否可以滚动 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Tint | tintColor | 所有子View的继承色 | Hidden | isHidden | 是否隐藏 |
|
Text Input Trait | 输入时候详细设定键盘的动作
项目名 | 属性/方法 | | Content Type | textContentType | 内容种类 设定后输入时会自动补全 | Capitalization | autocapitalizationType | 是否首字母大写 | Correction | autocorrectionType | 是否自动修正输入错误 | Smart Dashes | smartDashesType | 是否自动转换dash https://zh.wikipedia.org/wiki/%E8%BF%9E%E6%8E%A5%E5%8F%B7 | Smart Insert | smartInsertDeleteType | 粘贴和删除时是否自动处理空格 | Smart Quotes | smratQuotesType | 是否自动转换 | Spell Check | spellCheckingType | 是否检查拼写错误 | Keyboard Type | keyboardType | 键盘种类 | Keyboard Look | keyboardAppearance | 键盘style | Return Key | returnKeyType | return键的种类 | Auto Enable Return Key | enablesReturnKeyAutomatically | 是否自动切换return键的有效/无效 | Secure Text Entry | isSecureTextEntry | 是否遮盖输入内容(类似password) | | | | | | |
|
focus操作 | 目前聚焦的叫做 First Responder
获取聚焦 | 对象.becomeFirstResponder() | 取消聚焦 | 对象.resignFirstResponder() 关闭键盘可以理解为算是取消聚焦 |
|
事件操作 | 可以直接连接action, 也可以用delegate |
| |
| |
| |
UITextView |
| 输入多行的文本 |
设定项目 |
项目名 | 属性/方法 | | Text | text | 输入的文字 | Color | textColor | 文字颜色 | Font | font | 文字字体 | Alignment | textAlignment | 文字位置 | Border Style | borderStyle | 边线的种类 | Clear Button | clearButtonMode | 清除内容的按钮的表示方法 | Text Input Traits | | | Enabled | isEnabled | 此UI是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Tint | tintColor | 所有子View的继承色 | Hidden | isHidden | 是否隐藏 | Background(Image) | backgroundImage | 背景图 | Disabled(Image) | disabledBackground | 无效时的背景图 | | | |
|
| |
| |
| |
| |
| |
| |
UISegmentedController |
| 从多个值里选一个 |
设定项目 |
项目名 | 属性/方法 | | Segments | 不存在 | 选项的个数 | SegmentTitle | setTiele | 选项的标题 | Segment Image | setImage | 选项的图片 | Segment Enabled | setEnabled | 选项是否有效(可选) | Segment Selected | selectedSegmentIndex | 是否被选中 (选中的index) | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Tint | tintColor | 子类继承色 | Hidden | isHidden | 是否隐藏 | | | |
|
| |
| |
| |
| |
| |
| |
UIStepper |
| 以固定增幅增减数值 |
设定项目 |
项目名 | 属性/方法 | | Value | value | 现在的值 | Minimun | minimumValue | 最小值 | Maximum | maximumValue | 最大值 | Step | stepValue | 一次变化的值 | Autorepeat | autorepeat | 长按是否自动变化 | Continuous | isContinuous | 长按是否持续发出事件(消息) ● 设为false则长按结束前不会改变值 长按结束后一次性变到新值 | Wrap | wraps | 超过上下限是否回到另一端开头 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Tint | tintColor | 文字与边线的颜色 | Hidden | isHidden | 是否隐藏 | | | | | | | | | |
|
| |
| |
| |
| |
| |
| |
UISwitch |
| |
设定项目 |
项目名 | 属性/方法 | | State | isOn | 是否On | On Tint | onTintColor | On时候的背景色与边线颜色 | Thumb Tint | thumbTintColor | 内部圆和OFF时的边线颜色 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景颜色 | Hidden | isHidden | 是否不表示 | | | | | | |
|
| |
| |
| |
| |
| |
| |
UISlide |
| 滚动条输入数值 |
设定项目 |
项目名 | 属性/方法 | | Value | value | 现在的值 | Minimum | minimumValue | 最小值 | Maximum | maxmumValue | 最大值 | Min Image | minimunValueImage | 左侧表示的图象 | Max Image | maxmumValueImage | 右侧表示的图象 | Min Track | minimunTrackTintColor | 左侧的线的颜色 | Max Track | maxmumTrackTintColor | 右侧的线的颜色 | Thumb Tint | thumbTintColor | 圆的颜色 | Continuous Updates | isContinuous | 滑动时是否发出事件 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 |
|
| |
| |
| |
| |
| |
| |
UIActivityIndicatorView |
| 读取中等 |
设定项目 |
项目名 | 属性/方法 | | Style | activityIndicatorViewStyle | 指示器的样式 | Color | color | 指示器的颜色 | Animating | isAnimating | 是否展示动画 | Hides When Stopped | hidesWhenStopped | 停止动画后是否隐藏 | Enabled | isEnabled | 是有有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 | | | |
|
方法 |
显示 |
indicator.startAnimating()
| 隐藏 |
indicator.stopAnimating()
|
|
| |
| |
| |
| |
| |
UIProgressView |
| 进度条 |
设定项目 |
项目名 | 属性/方法 | | Style | progressViewStyle | 进度条样式 | Progress | progress | 进度 Float 0.0 ~ 1.0 | Progress Tint | progressTintColor | 左侧颜色 | Track Tint | trackTintColor | 右侧颜色 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Hidden | isHidden | 是否隐藏 | | | |
|
| |
| |
| |
| |
| |
| |
UIPickerView |
| 多选项选择 |
设定项目 |
项目名 | 属性/方法 | | Enabled | isEnabled | 是否可用 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 | | | |
|
| |
| |
| |
| |
| |
| |
UIDatePicker |
| 选择日期 |
设定项目 |
项目名 | 属性/方法 | | Mode | datePickerMode | 选择器的样式 | Locale | locale | 位置 | Interval | minuteInterval | 分钟间隔 | Date | date | 选中的日期 | Minimum Date | minimumDate | 最小日期 | Maximum Date | maxmumDate | 最大日期 | Timer | countDownDuration | 倒计时 | Enabled | isEnabled | 是有有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 | | | |
|
Date操作 | DateFormatter |
| |
| |
| |
| |
| |
| |
| |
UIBarButtonItem |
| 向工具条(tool bar)或者导航条(navigation bar)上配置的按钮 |
设定项目 |
项目名 | 属性/方法 | | Style | style | item的样式 | System Item | 初始化的参数(init) | 系统item的种类 | Title | title | 标题 | image | image | 图象 | Landscape Image | landscapeImagePhone | 横向画面时使用的图片 | Enabled | isEnabled | 是有有效 | | | |
|
| // TODO: 增加实例 |
| |
| |
| |
| |
| |
UIPageControl |
| |
设定项目 |
项目名 | 属性/方法 | | Pages | numberOfPages | 页数 | Defers Page Display | defersCurrentPageDisplay | 设定为true则 直到呼出updateCurrentPageDisplay 不会换页 | Tint Color | pageIndicatorTintColor | 未选择的页的颜色 | Current Page | currentPageIndicatorTintColor | 当前选择页面的颜色 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 | | | |
|
| |
| |
| |
| |
| |
| |
UIRefreshControl |
| // TODO: 增加实例 |
| |
| |
| |
| |
| |
| |
| |
UIWKWebView |
| WebView就用这个 ● iOS8以后不推荐用UIWebView |
设定项目 |
项目名 | 属性/方法 | | User Agent | customUserAgent | 用户代理 | App Name | configuration.applicationNameForUserAgent | 用户代理内的app名 | Back/Forward Gestures | allowsBackForwardNavigartionGestures | 是否允许滑动前进后退 | Selection | configuration.selectionGranularity | 选择模式 | AirPlay | configuration.allowsAirPlayForMediaPlayback | 是否允许Aitplay | Inline Playback | configuration.allowsInlineMediaPlayback | 是否允许HTML5的video 行内播放 false则全屏播放 | Picture-in-Picture | configuration.allowsPictureinPictureMediaPlayback | 是否允许HTML5的video Picture-in-Picture播放 | Interaction | configuration.mediaTypesRequiringUserActionForPlayback | 播放media是否需要用户操作触发 | Data Detectors | configuration.dataDetectorTypes | 探测数据并放置链接 | JavaScript | configuration.preferences.JavaScriptEnabled | 是有有效化JavaScript | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 |
|
| |
| |
| |
| |
| |
| |
UIWebView |
| 尽量不用, 需要webView但WKWebView太复杂的时候用SFSafariViewController |
设定项目 |
项目名 | 属性/方法 | | Scales Page To Fit | scalesPageToFit | 调整内容大小填入UIWebView | Data Detectors | dataDetectorTypes | 探测数据并放置链接 | Allows Inline Playback | allowsInlineMediaPlayback | 是否允许HTML5 视频 inline或全屏播放 | Playback Requires User Action | mediaPlaybackRequiresUserAction | 播放是否需要用户触发 | Keyboard Display Requires User Action | keyboardDisplayRequiresUserAction | 表示键盘是否需要用户触发 | Enabled | isEnabled | 是否有效 | Alpha | alpha | 不透明度 | Background | backgroundColor | 背景色 | Hidden | isHidden | 是否隐藏 |
|
| |
| |
| |
| |
| |
| |