[非凡程序员]UIKit 手写控件
2015-11-11 00:00
239 查看
//
// ViewController.m
// 手写控件
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 300, 200)];
//标签文字内容
lable.text=@"CuiXiaoYu";
//标签文字字体格式和字体大小
lable.font=[UIFont fontWithName:@"Zapfino" size:30];
//设置标签字体颜色
lable.textColor=[UIColor yellowColor];
//设置圆角边框的角度
lable.layer.cornerRadius=20;
//设置背景颜色
lable.backgroundColor=[UIColor redColor];
//设置标签边框的颜色
lable.layer.borderColor=[UIColor blackColor].CGColor;
//设置标签边框的宽度
lable.layer.borderWidth=20;
//标签文字居中
lable.textAlignment=NSTextAlignmentCenter;
//将控件添加到当前图层上
[self.view addSubview:lable];
// --------关于UITextFeild--------
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(20, 400, 100, 80)];
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
button.backgroundColor=[UIColor orangeColor];
[button addTarget:self action:@selector(diJi:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)diJi:(UIButton *)b{
NSLog(@"点了~");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
// ViewController.m
// 手写控件
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *lable=[[UILabel alloc]initWithFrame:CGRectMake(20, 20, 300, 200)];
//标签文字内容
lable.text=@"CuiXiaoYu";
//标签文字字体格式和字体大小
lable.font=[UIFont fontWithName:@"Zapfino" size:30];
//设置标签字体颜色
lable.textColor=[UIColor yellowColor];
//设置圆角边框的角度
lable.layer.cornerRadius=20;
//设置背景颜色
lable.backgroundColor=[UIColor redColor];
//设置标签边框的颜色
lable.layer.borderColor=[UIColor blackColor].CGColor;
//设置标签边框的宽度
lable.layer.borderWidth=20;
//标签文字居中
lable.textAlignment=NSTextAlignmentCenter;
//将控件添加到当前图层上
[self.view addSubview:lable];
// --------关于UITextFeild--------
UIButton *button=[[UIButton alloc]initWithFrame:CGRectMake(20, 400, 100, 80)];
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
button.backgroundColor=[UIColor orangeColor];
[button addTarget:self action:@selector(diJi:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)diJi:(UIButton *)b{
NSLog(@"点了~");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
相关文章推荐
- UIKit 手写控件转换大小写
- Request对象
- 常用控件—UILabel
- Range Sum Query
- MiniGui3.0.12在主机上的配置及在开发板上的移植
- IOS UIImageView
- leetcode之Range Sum Query - Immutable
- UEFI Console Splitter 2nd
- Looper.myLooper().quit() 报 NullPointerException
- 进击的KFC:UI(一)UIView及其子类
- 爬爬爬之路:UI(一) UIView UILabel
- [TwistedFate]UIView UILabel
- UI学习第一天UIView 和UILabel
- hdu1159 Common Subsequence (最长公共子序列)
- 我的iOS学习历程 - UIView和UILabel
- 我的iOS学习历程 - UIView和UILabel
- 新手学EasyUI(七)----DataGrid CheckBox 动态选中
- UI第一天UIView
- UI基础知识 -- UIView UILabel
- UI基础-UIView及其子类