需求要实现上图下文,现在写得是有点乱的了,以后再慢慢整理吧。
UIButton
A control that executes your custom code in response to user interactions.
Declaration
class UIButton : UIControl
Overview
设计一个UIButton的常规步骤:
When adding a button to your interface, perform the following steps:
Set the type of the button at creation time. //创建之初,先设置button的风格
Supply a title string or image; size the button appropriately for your content. //应用图片或者标题字符串来规划button
Connect one or more action methods to the button. //连接一个或者多个 动作方法 来连接button
Set up Auto Layout rules to govern the size and position of the button in your interface.
//设置自动布局规则来规划你的button尺寸和位置
Provide accessibility information and localized strings. //提供访问button的信息和本地化的字符串
点击按钮时的响应方式:
Buttons use the Target-Action(link) design pattern to notify your app when the user taps the button.
Button是基于 目标-行为 的设计模式来通知你的app的,当客户点击按钮时就会触发该模式
Rather than handle touch events directly, you assign action methods to the button and designate which events trigger calls to your methods.
Button不直接对事件进行响应,而是通过 你指定的方法 来响应 你指定的动作事件 。
You connect a button to your action method using the
addTarget(_:action:for:)(link)
method or by creating a connection in Interface Builder.你通过UIButton的