UILTview

/***********************************************************************************/

#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 mainScreenbounds]];

    self.window.backgroundColor =[UIColor whiteColor];

    [self.window makeKeyAndVisible];

    [_window release];

    UIViewController *vc=[[UIViewController alloc]init];

    self.window.rootViewController =vc;

    [vc release];

    

    

    

  LTView *view = [[LTView alloc] initWithFrame:CGRectMake(0, 0, self.window.frame.size.width,80 )];

    view.backgroundColor =[UIColor yellowColor];

    [self.window addSubview:view];

    [view release];

    view.label.text =@"姓名";

    view.textField.placeholder =@"请输入姓名";


    

    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"];



    

//    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);

//}


// /
#import <UIKit/UIKit.h>


@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 = [super initWithFrame:frame];

    if (self)

    {

        //创建两个视图

        [self createView];

    }

    return self;

}

-(void)createView

{

    self.label =[[UILabel alloc]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 =[[UITextField alloc]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.textField resignFirstResponder];

    return  YES;

}

-(void)dealloc

{

    [_label release];

    [_textField release];

    [super dealloc];

}


@end



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值