UILTview
来源:互联网 发布:豆瓣知乎天涯的区别 编辑:程序博客网 时间:2024/06/04 23:28
/***********************************************************************************/
#import "AppDelegate.h"
#import "LTView.h"
@interface AppDelegate ()<UIAlertViewDelegate>
@end
@implementation AppDelegate
-(void)dealloc
{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window =[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.backgroundColor =[UIColor whiteColor];
[self.window makeKeyAndVisible];
[_window release];
UIViewController *vc=[[UIViewController alloc]init];
self.window.rootViewController =vc;
[vc release];
LTView *view = [[LTViewalloc] initWithFrame:CGRectMake(0,0, self.window.frame.size.width,80 )];
view.backgroundColor =[UIColoryellowColor];
[self.windowaddSubview:view];
[view release];
view.label.text =@"姓名";
view.textField.placeholder =@"请输入姓名";
UIImageView *image =[[UIImageViewalloc] initWithFrame:CGRectMake(80,80, 200, 200)];
image.backgroundColor =[UIColorredColor];
[self.windowaddSubview:image];
[image release];
image.image =[UIImageimageNamed:@"/Users/dllo/Desktop/UI03_LTView/UI03_LTView/asdasd.jpg"];
// UIImageView *image =[[UIImageView alloc] initWithFrame:CGRectMake(80, 80, 200, 200)];
// image.backgroundColor =[UIColor redColor];
// [self.window addSubview:image];
// [image release];
// image.image =[UIImage imageNamed:@"/Users/dllo/Desktop/UI03_LTView/UI03_LTView/asdasd.jpg"];
///UIAlertView
// UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"程锦乐" message:@"真的吗" delegate:self cancelButtonTitle:@"真的" otherButtonTitles:@"假的", nil];
////UIActionSheet
//// 给提示窗口加入输入框
// alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
// [alert show];
return YES;
}
**** UIAlertView的方法 用的时候需要签协议
//-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
//{
// NSLog(@"%ld",buttonIndex);
// ///获取输入内容
// UITextField *text =[alertView textFieldAtIndex:0];
// NSLog(@"%@",text.text);
//}
@interface LTView :UIView<UITextFieldDelegate>
@property(nonatomic,retain)UILabel *label;
@property(nonatomic,retain)UITextField *textField;
@end
//////////////////////
#import "LTView.h"
@implementation LTView
//为了创建一个LTView就可以同时把两个视图都创建出来,所以重写初始化方法
-(id)initWithFrame:(CGRect)frame
{
self = [superinitWithFrame:frame];
if (self)
{
//创建两个视图
[self createView];
}
return self;
}
-(void)createView
{
self.label =[[UILabelalloc]initWithFrame:CGRectMake(20,20,150,50 )];
self.label.layer.borderWidth =1;
self.label.layer.cornerRadius =25;
self.label.layer.masksToBounds =YES;
self.label.textAlignment =1;
[self addSubview:self.label];
[_label release];
self.textField =[[UITextFieldalloc]initWithFrame:CGRectMake(180,20, 150, 50)];
self.textField.layer.borderWidth =1;
self.textField.layer.cornerRadius=25;
self.textField.clearButtonMode =UITextFieldViewModeAlways;
[self addSubview:self.textField];
[_textField release];
self.textField.delegate =self;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
[self.textFieldresignFirstResponder];
return YES;
}
-(void)dealloc
{
[_label release];
[_textField release];
[super dealloc];
}
@end
- UILTview
- UILTView经典知识点练习
- html表单使用
- gym database architecture
- 关于Gradle的一些内容
- 虚拟机配置Centos7方法
- Hibernate中配置文件hibernate.cfg.xml详解
- UILTview
- tomcat启动java.lang.UnsupportedClassVersionError
- div 设置宽高度问题
- 安卓屏幕--Android屏幕适配经验谈
- Hadoop:序列化和反序列化
- 【SSH快速进阶】——Hibernate 多对多映射
- ajax配合java简单案例
- ProgressBar简单使用(1)
- Java中字符串中子串的查找共有四种方法(indexof())