UIButton、UIImageView、UILabel的选择

UIButton
特点
既能显示文字,又能显示图片(能显示2张图片,背景图片、内容图片)
长按高亮的时候可以切换图片\文字
直接通过addTarget...方法监听点击

UIImageView
能显示图片,不能直接通过addTarget...方法监听点击

UILabel
能显示文字,不能直接通过addTarget...方法监听点击

选择
仅仅是显示数据,不需要点击
建议选择UIImageView、UILabel

不仅显示数据,还需要监听点击
建议选择UIButton
其实UIImageView、UILabel也可以通过手势识别器来监听

长按控件后,会改变显示的内容
不用考虑了,选择UIButton(因为UIButton有highlighted这种状态)

同时显示2张图片:背景图片、内容图片
不用考虑了,选择UIButton

时间: 2024-08-07 04:11:27

UIButton、UIImageView、UILabel的选择的相关文章

iOSDay21之UILabel, UITextField, UIButton, UIImageView

1.UILabel 1> 概述 UILabel (标签): 是显示本的控件.在App中 UILabel 是出现频率最高的控件 UILabel 是 UIView 子类,作为子类 般是为了扩充父类的功能UILabel扩展了文字显示的功能, UILabel 是能显示文字的视图. 2> 创建UILabel的步骤 创建UILabel与创建UIView的步骤很相似. 开辟空间并初始化(如果本类有初始化方法,则使用自己的初 始化方法;否则使用父类的) 设置文本控制相关的属性 添加到父视图上,用以显示 释放所

你真的了解UIButton、UILabel 吗?

一:首先查看一下关于UIButton的定义 @class UIImage, UIFont, UIColor, UIImageView, UILabel; //设置UIButton的样式 typedef NS_ENUM(NSInteger, UIButtonType) { UIButtonTypeCustom = 0, // 自定义,无风格 UIButtonTypeSystem NS_ENUM_AVAILABLE_IOS(7_0), // standard system button UIButt

UIButton、UILabel、UITextField 初学者需要了解的基本定义和常用设置

 以下是三个IOS开发中最常用的控件,作为IOS基础学习教程知识 ,初学者需要了解其基本定义和常用设置,以便在开发在熟练运用. UIButton按钮 第一.UIButton的定义 UIButton *button=[[UIButton buttonWithType:(UIButtonType); 能够定义的button类型有以下6种, typedef enum { UIButtonTypeCustom = 0,  自定义风格 UIButtonTypeRoundedRect,  圆角矩形 UIBu

基础控件之UIButton.UIImageView基本属性与方法概览

1 1.UIButton->UIView 按钮 2 /************UIButton-System(文字样式)**********/ 3 //按钮实例化方式:类方法创建 4 /* 5 1.UIButtonTypeSystem=UIButtonTypeRoundedRect iOS7之后 6 2.UIButtonTypeRoundedRect iOS7之前有效,iOS7之后无效果 7 3.UIButtonTypeInfoLight = UIButtonTypeInfoDark = UIB

UIButton,UIImageView,UITextField

1.UIButton的基本设置 1 //创建UIButton 2 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 3 button.frame = CGRectMake(150, 200, 70, 40); 4 button.backgroundColor = [UIColor redColor]; 5 /** 6 * 设置按钮标题 7 * 标题内容 8 * 按钮状态 9 */ 10 11 [button setT

iOS开发之代码创建常用控件(UIButton、UILabel)的思路

代码创建按钮UIButton: (一)基本设置 //创建中间“+”按钮 UIButton *addBtn = [[UIButton alloc] init]; //设置默认背景图片 [addBtn setBackgroundImage:[UIImage imageNamed:@"AddButtonIcon"] forState:UIControlStateNormal]; //设置按下时背景图片 [addBtn setBackgroundImage:[UIImage imageName

设置UIButton或者UILabel显示文字的行数

需要在UIButton的titleLabel或者UILabel的text 字符串里面添加换行符号 “\n”,并且设置 UILabel的numberOfLines属性 栗子:行数要和“\n”的个数对应,并且UILabel的frame要保证足够大,能够完整显示换行之后的文字 代码: 截图: 1.字体格式设置过大的结果 2. 设置刚好的结果 4.设置3行的字体格式过大的结果 -------------------------> 5.行数和换行符不对应的结果 ----------------------

UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法

在iOS开发中,任何可见视图都是继承于UIView的.    继承体系中,大部分UIView的属性适用于其任何孩子. 而UIView的layer属性可以绘制UIView的各种效果.其实我们看到的View的动画实际上也是layer在绘制. 1.绘制圆角 cornerView.layer.cornerRadius = 20; cornerView.layer.masksToBounds = YES; masksToBounds防止子元素溢出父视图. 如果一个正方形要设置成圆形,代码为: corner

iOS开发UI之UIButton的基本使用

一. 继承关系: UIButton --> UIControl --> UIView 二. 什么是按钮 UIButton既能显示文字,又能显示图片,还能随时调整内部图片和文字的位置 三. UIButton的状态 UIControlStateNormal : 默认状况 UIControlStateHighlighted : 高亮状态(按钮被按下去的时候,既为手指还未松开) UIControlStateDisabled : 失效状态,不可用状态 如果enable = NO,处于disable状态,