iOS学习应用开发就业课_004:UIButton时间处理

难点:

1.创建2个UIButton的时间

  a按钮:移动View

 b按钮:回复位置

2.保证View的移动


复习次数:5次

5月13日

5月16日

5月26日

5月30日

5月31日


源码:

- (void)viewDidLoad {

    [super viewDidLoad];

    UIButton *myBtn1=[UIButton buttonWithType:UIButtonTypeRoundedRect];

    myBtn1.frame=CGRectMake(50, 500, 80, 40);

    [myBtn1 setTitle:@"按下移动" forState:UIControlStateNormal];

    [myBtn1 addTarget:self action:@selector(pressMove) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:myBtn1];

    

    UIButton *myBtn2=[UIButton buttonWithType:UIButtonTypeRoundedRect];

     myBtn2.frame=CGRectMake(50, 150, 80, 40);

    [myBtn2 setTitle:@"按下移动" forState:UIControlStateNormal];

    [myBtn2 addTarget:self action:@selector(pressRect) forControlEvents:UIControlEventTouchUpInside];

    [self.view addSubview:myBtn2];

    

    

    UIView *vc=[[UIView alloc] initWithFrame:CGRectMake(1, 250, 100, 100)];

    vc.backgroundColor=[UIColor yellowColor];

    vc.tag=101;

    [self.view addSubview:vc];

    

}


-(void)pressMove

{

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

    vc=[self.view viewWithTag:101];

    vc.backgroundColor=[UIColor darkGrayColor];

    vc.frame=CGRectMake(vc.frame.origin.x+10, vc.frame.origin.y+50, 200, 200);

    [self.view addSubview:vc];

    

    

}


-(void)pressRect

{

    

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

    vc=[self.view viewWithTag:101];

    vc.frame=CGRectMake(1, 250, 100, 100);


}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值