iOS开发系列之四 – UITextView 用法小结

// 初始化输入框并设置位置和大小
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, 300, 180)];
// 设置预设文本
textView.text = @"";
// 设置文本字体
textView.font = [UIFont fontWithName:@"Arial" size:16.5f];
// 设置文本颜色
textView.textColor = [UIColor colorWithRed:51/255.0f green:51/255.0f blue:51/255.0f alpha:1.0f];
// 设置文本框背景颜色
textView.backgroundColor = [UIColor colorWithRed:254/255.0f green:254/255.0f blue:254/255.0f alpha:1.0f];
// 设置文本对齐方式
textView.textAlignment = NSTextAlignmentLeft;

iOS开发系列之三 – UITextField 用法小结

// 初始化输入框并设置位置和大小
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)];
// 设置输入框提示
textField.placeholder = @"TextField Tip";
// 输入框中预先输入的文字
textField.text = @"预先输入的文字";
// 设置输入框文本的字体
textField.font = [UIFont fontWithName:@"Arial" size:20.0f];
// 设置输入框字体颜色
textField.textColor = [UIColor redColor];
// 设置输入框的背景颜色
textField.backgroundColor = [UIColor grayColor];
// 设置输入框边框样式
textField.borderStyle = UITextBorderStyleRoundedRect;

iOS开发系列之二 – UILabel 用法小结

// 初始化标签
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 300, 150)];
// 设置标签文字
label.text = @"This is a test text.This is a test text.This is a test text.";
// 设置标签文字字体
// 使用系统字体
label.font = [UIFont systemFontOfSize:20];
// 使用系统字体加粗
//label.font = [UIFont boldSystemFontOfSize:20];
// 指定字体
//label.font = [UIFont fontWithName:@"Arial" size:20];
// 设置标签文字颜色
label.textColor = [UIColor redColor];
// 设置标签背景颜色
label.backgroundColor = [UIColor clearColor];
// 设置标签文字对齐方式
label.textAlignment = NSTextAlignmentCenter;

iOS开发系列之一 – UIButton 用法小结

// 初始化按钮并设置类型
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];

// 能够定义的UIButton类型有以下6种:
//    typedef enum {
//        UIButtonTypeCustom = 0,          自定义风格
//        UIButtonTypeRoundedRect,         圆角矩形
//        UIButtonTypeDetailDisclosure,    蓝色小箭头按钮,主要做详细说明用
//        UIButtonTypeInfoLight,           亮色感叹号
//        UIButtonTypeInfoDark,            暗色感叹号
//        UIButtonTypeContactAdd,          十字加号按钮
//    } UIButtonType;