简单代码实现(补昨天的.....)

//  按钮的实现

//  ViewController.m

//  按钮练习

//

//  Created by 李博 on 16/1/13.

//  Copyright © 2016 李博. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIButton *lufei;


@property (weak, nonatomic) IBOutlet UITextField *txtnum1;

@property (weak, nonatomic) IBOutlet UITextField *txtnum2;

@property (weak, nonatomic) IBOutlet UILabel *result;

@end


@implementation ViewController

- (IBAction)up:(id)sender {

    CGPoint frame =self.lufei.center;

    frame.y+=5;

    self.lufei.center=frame;

}

- (IBAction)bigger:(id)sender {

    CGRect a=self.lufei.bounds;

    a.size.height+=5;

    a.size.width+=5;

    self.lufei.bounds=a;

}

- (IBAction)jisuan:(id)sender {

    //接收值

    NSString *num1=self.txtnum1.text;

    NSString *num2=self.txtnum2.text;

    int a = [num1 intValue];

    int b = [num2 intValue];

    int m = a+b;

    self.result.text=[NSString stringWithFormat:@"%d",m];

    //回收键盘

    //[self.view endEditing:YES];

    [self.txtnum1 resignFirstResponder];

    [self.txtnum2 resignFirstResponder];

}

//通过纯代码的方式创建一个按钮

//1.注意是在系统创建的控制器的view中添加****


- (void)viewDidLoad {

    [super viewDidLoad];

    //1.先建一个按钮对象

    UIButton *button =[[UIButton alloc]init];

    //2.设置按钮显示的文字

    //默认状态下 deflout/normal

    [button setTitle:@"路飞" forState:UIControlStateNormal];

    //高亮状态下

    [button setTitle:@"摩托" forState:UIControlStateHighlighted];

    //3.设置按钮的背景图片

    //根据图片名称,创建图片对象

    UIImage *normal =[UIImage imageNamed:@"button_01"];

    UIImage *heighlighted =[UIImage imageNamed:@"button_02"];

    //默认状态下 背景图片是哪个

    [button setBackgroundImage:normal forState:UIControlStateNormal];

    //高亮状态下

    [button setBackgroundImage:heighlighted forState:UIControlStateHighlighted];

    //4.按钮位置的frame(位置,大小)

    button.frame=CGRectMake(100, 100, 100, 100);

    //5.设置按钮在不同状态下文字的yanse

    [button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];

    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];

    //6.添加到界面中

    [self.view addSubview:button];

    //按钮的事件 (单击事件)********注意方法的冒号

    [button addTarget:self action:@selector(didClickButton:) forControlEvents:UIControlEventTouchUpInside];

   

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

//- (void) didClickButton{

//    NSLog(@"你别按我!!");

//    UIView *A =[self.view viewWithTag:1];

//    [A removeFromSuperview];

//}

- (void) didClickButton:(UIButton *)sender{

    NSLog(@"你别按我!!%@",sender.currentTitle);

    

}

@end

/

qq登陆界面

//

//  ViewController.m

//  QQ登陆界面

//

//  Created by 李博 on 16/1/14.

//  Copyright © 2016 李博. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()

@property (weak, nonatomic) IBOutlet UITextField *txtQQNum;

@property (weak, nonatomic) IBOutlet UITextField *txtQQpassWord;


@end


@implementation ViewController

- (IBAction)didClickButton:(id)sender {

    NSString *qq =self.txtQQNum.text;

    NSString *password=self.txtQQpassWord.text;

    NSLog(@"qq账号 %@,密码%@",qq,password);

    [self.view endEditing:YES];

    

}


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值