// UIProgressView的使用 常用于歌曲的和下载的进度条
UIProgressView *oneProgressView = [[UIProgressView alloc] init];
oneProgressView.frame = CGRectMake(0, 30, 320, 30); // 设置UIProgressView的位置和大小
oneProgressView.backgroundColor = [UIColor clearColor]; // 设置背景色
oneProgressView.alpha = 1.0; // 设置透明度 范围在0.0-1.0之间 0.0为全透明
UISwitch的使用方法详细 - 技术篇
发表于
// UISwitch的使用
UISwitch *oneSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(20, 20, 0, 0)]; // 默认尺寸为79 * 27。
oneSwitch.backgroundColor = [UIColor greenColor]; // 设置背景色
oneSwitch.alpha = 1.0; // 设置透明度 范围在0.0-1.0之间 0.0是完全透明
oneSwitch.onTintColor = [UIColor redColor]; // 在oneSwitch开启的状态显示的颜色 默认是blueColor
oneSwitch.tintColor = [UIColor purpleColor]; // 设置关闭状态的颜色
oneSwitch.thumbTintColor = [UIColor blueColor]; // 设置开关上左右滑动的小圆点的颜色
UISlider的使用方法详细
发表于
|
分类于
技术篇
// UISlider的常用方法
UISlider *oneSlider = [[UISlider alloc] init];
// 最常用
oneSlider.frame = CGRectMake(10, 20, 300, 30); // 设置位置和大小 注意:UISlider的高度可以随便设置,因为是不会变的
oneSlider.value = 30; // 初始值
oneSlider.minimumValue = 0; // 最小值
oneSlider.maximumValue = 100; // 最大值
oneSlider.backgroundColor = [UIColor blueColor]; // 设置背景颜色
oneSlider.alpha = 0.9; // 设置透明度
oneSlider.tag = 1001; // 设置标签,常用在委托中
UITextFiled的使用方法详细
发表于
|
分类于
技术篇
// UITextField的常用方法
UITextField *oneTextField = [[UITextField alloc] init];
// 最常用
oneTextField.frame = CGRectMake(30, 30, 260, 35); // 设置位置
oneTextField.backgroundColor = [UIColor grayColor]; // 设置背景颜色
oneTextField.alpha = 1.0; // 设置透明度,范围从0.0-1.0之间
oneTextField.textColor = [UIColor redColor]; // 设置文字的颜色
UIButton的使用方法详细
发表于
|
分类于
技术篇
// UIButton的常用方法
UIButton *oneButton = [UIButton buttonWithType:UIButtonTypeCustom];
// 初始化时设置Button样式
// 风格有如下
// typedef enum {
// UIButtonTypeCustom = 0, // 自定义,无风格
// UIButtonTypeRoundedRect, // 白色圆角矩形,类似偏好设置表格单元或者地址簿卡片
// UIButtonTypeDetailDisclosure,//蓝色的披露按钮,可放在任何文字旁
// UIButtonTypeInfoLight,//微件(widget)使用的小圆圈信息按钮,可以放在任何文字旁
// UIButtonTypeInfoDark,//白色背景下使用的深色圆圈信息按钮
// UIButtonTypeContactAdd,//蓝色加号(+)按钮,可以放在任何文字旁
// } UIButtonType;
UILabel的使用方法详细
发表于
|
分类于
技术篇
//UILabel的使用
UILabel *oneLabel = [[UILabel alloc] init];
// 最经常使用的
oneLabel.frame = CGRectMake(0, 0, 320, 200); // 设置oneLabel的位置和大小
oneLabel.text = @"我是一个UILabel哦,"; // 设置oneLabel显示的字
oneLabel.textColor = [UIColor blackColor]; // 设置字体颜色
oneLabel.backgroundColor = [UIColor redColor]; // 设置背景色
oneLabel.backgroundColor = [UIColor clearColor]; // 可以设置透明背景色
oneLabel.alpha = 1.0; // 设置透明度 (范围是0.0-1.0之间)
iOS基础 -- 一些常用的小知识总结
发表于
|
分类于
技术篇
把图片做成圆形图标
self.headIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 40, 40)] ;
self.headIconImageView.layer.cornerRadius = 20 ; // 设置半径
self.headIconImageView.layer.masksToBounds = YES ; // 边界是否允许截取
各种占位符
发表于
|
分类于
技术篇
Block的使用
发表于
|
分类于
技术篇
Block:
1.
//代码块的声明
void (^aBlock) (NSString *str);
// 代码块变量的赋值
aBlock = ^(NSString *str){
NSLog(@"%@", str);
};
NSArray和NSMutableArray
发表于
|
分类于
技术篇
NSArray:
只能存放对象。不能存放C语言中基本的数据类型。如int/double/float等等
数组下标越界不会有警告,运行时会直接报错
// 不可变数组NSArray
// 在数组从存入nil需要使用NSNull,不可以直接存入nil,因为在数组中nil代表数组结束
NSNull *n = [NSNull null];