iOS 之 UILable和UITextFiled的自定义
来源:互联网 发布:龙记模胚报价软件 编辑:程序博客网 时间:2024/05/16 00:26
解析:
label 一般是作为接收信息用的,默认是不能更改的,而textFiled是可更改的,一般作为输入框,也可作为接收框
下面介绍一些创建的有关label和textFiled的属性用法
创建一个singleView,继承UITableView类
在.h文件中创建一个UILable和一个UITextFiled的对象
//
// LYXViewController.h
// helloWord
//
// Created by liyongxing on 13-7-2.
// Copyright (c) 2013年 liyongxing. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LYXViewController :UIViewController
@property (nonatomic ,strong)UILabel * lable;
@property (nonatomic ,strong)UITextField * textFile;
@end
//
// LYXViewController.m
// helloWord
//
// Created by liyongxing on 13-7-2.
// Copyright (c) 2013年 liyongxing. All rights reserved.
//
#import "LYXViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface LYXViewController ()<UITextFieldDelegate>
@end
@implementation LYXViewController
- (void)viewDidLoad
{
[superviewDidLoad];
//创建helloWord的接收框
self.lable = [[UILabelalloc]initWithFrame:CGRectMake(20,50,200,40)];
//设置lable的颜色
self.lable .backgroundColor = [UIColorbrownColor];
//给lable赋值
self.lable.text = @"Lee-YongXing @ Li-Yongxing";
//设置内容的字体、大小和加粗的方法
self.lable.font = [UIFontfontWithName:@"Arial"size:20.0f];
//字体加粗的方法
self.lable.font = [UIFont boldSystemFontOfSize:20.0f];
//字体的颜色
[self.lablesetTextColor:[UIColorredColor]];
//根据字体的大小,高度自适应
self.lable.adjustsFontSizeToFitWidth =YES;
//内容的简单排版
//self.lable.textAlignment = UITextAlignmentCenter;
// self.lable.textAlignment = UITextAlignmentLeft;
// self.lable.textAlignment = UITextAlignmentRight;
[self.lablesetTextAlignment:NSTextAlignmentCenter];
//内容的行数
self.lable.numberOfLines =0;
//内容是否可以删改
// self.lable.enabled = NO;
//设置label的透明度,里面的内容也会跟着透明度变化
//self.lable.alpha = 0.5;
//设置lable的背景色为透明色
//self.lable.backgroundColor = [UIColor clearColor];
//设置背景图片,原则是,能不用UIImageView就不用
// self.lable.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"aa.jpg"]];
//如果输入内容过多,截去中间部分
self.lable.lineBreakMode = UILineBreakModeMiddleTruncation;
//设置边角的弧度
self.lable.layer.cornerRadius = 10.0f;
self.lable.layer.masksToBounds = YES;
//设置lable的边框颜色
self.lable.layer.borderColor = [[UIColor blueColor] CGColor];
self.lable.layer.borderWidth = 1.0f;
self.lable.layer.cornerRadius = 10.0f;
self.lable.clipsToBounds = TRUE;
[self.view addSubview:lable];
//设置阴影的颜色和阴影的偏移位置
self.lable.shadowColor = [UIColorredColor];
self.lable.shadowOffset =CGSizeMake(2.0,1.0);
[self.viewaddSubview:self.lable ];
//-------创建一个输入框----------
self.textFile = [[UITextFieldalloc]initWithFrame:CGRectMake(20,120,200,40)];
//设置text的颜色
self.textFile.backgroundColor = [UIColorbrownColor];
//设置边角弧度
self.textFile.layer.cornerRadius = 10.0f;
self.textFile.layer.masksToBounds = YES;
//设置背景字,当输入字的时候被自动删除掉
self.textFile.placeholder = @"I LOVE YOU ";
//设置边框的类型
self.textFile.borderStyle = UITextBorderStyleBezel;
//键盘输入完成后时的推出按钮
self.textFile.returnKeyType = UIReturnKeyDone;
//这个是文本的上下居中
self.textFile.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
//清除键,当输入完后想把内容全部删除,按这个按钮,全部删除
self.textFile.clearButtonMode = UITextFieldViewModeAlways;
//实现代理方法
self.textFile.delegate =self;
[self.viewaddSubview:self.textFile];
}
//<----------------实现textFile代理方法----------------->
-(void)textFieldDidBeginEditing:(UITextField *)textField
{
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
}
- (void)didReceiveMemoryWarning
{
[superdidReceiveMemoryWarning];
}
@end
- iOS 之 UILable和UITextFiled的自定义
- iOS之UITextView和UITextFiled的区别
- UI基础之----UITextFiled,UIButton,UILable
- ios-自定义UITextFiled的属性设置
- IOS UITextView和UITextFiled的区别
- iOS的UIButton和UILable
- OC UILable UITextFiled UIButton
- iOS--UITextFiled的使用方法
- 04-常用UI控件之 UIlable UIButton UITextFiled
- IOS之UILable删除线的设置
- IOS开发之UILable
- iOS新手入门之UILable
- iOS:UITextFiled控件的设置
- iOS--UITextFiled的使用方法详细
- IOS--UITextFiled的使用方法详细
- iOS UITextfiled
- IOS关于uitextfiled的使用攻略
- IOS-UITextFiled常见的委托代理使用方法
- 架构师到底是什么
- hash表原理
- POJ-1328-Radar Installation
- SQL INSERT INTO 语句
- aix 禁止root远程登录
- iOS 之 UILable和UITextFiled的自定义
- 进程的三种基本状态
- Struts视频笔记
- "The Moment" - Audi App Jam (Day 2)
- 解析全球级分布式数据库Google Spanner
- POJ-1323-Game Prediction
- Android中检测软键盘的弹出和关闭
- 嵌入式智能家居
- iterator