码迷,mamicode.com
首页 > 其他好文 > 详细

关于btn

时间:2016-10-21 16:47:20      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:图片   action   

适配图片

UIImage *buttonImage = [UIImage imageNamed:@"go_work_green"];

    UIImage *stretchableButtonImage = [buttonImage  stretchableImageWithLeftCapWidth:0  topCapHeight:0];

    [goBtn setBackgroundImage:stretchableButtonImage  forState:UIControlStateNormal];

圆角

goBtn.layer.cornerRadius = kScreenW/6;

点击缩放

[self.ordersBtn addTarget:self action:@selector(unpressedEvent:) forControlEvents:UIControlEventTouchUpInside | UIControlEventTouchUpOutside];

        [self.ordersBtn addTarget:self action:@selector(pressedEvent:) forControlEvents:UIControlEventTouchDown];

        [self.ordersBtn addTarget:self action:@selector(cancelEvent:) forControlEvents:UIControlEventTouchUpOutside];


//按钮的压下事件 按钮缩小

- (void)pressedEvent:(UIButton *)btn{

    //缩放比例必须大于0,且小于等于1

    CGFloat scale = (_buttonScale && _buttonScale <=1.0) ? _buttonScale : defaultScale;

    

    [UIView animateWithDuration:animateDelay animations:^{

        btn.transform = CGAffineTransformMakeScale(scale, scale);

    }];

}

//点击手势拖出按钮frame区域松开,响应取消

- (void)cancelEvent:(UIButton *)btn{

    [UIView animateWithDuration:animateDelay animations:^{

        btn.transform = CGAffineTransformMakeScale(1.0, 1.0);

    } completion:^(BOOL finished) {

        

    }];

}

//按钮的松开事件 按钮复原 执行响应

- (void)unpressedEvent:(UIButton *)btn{

    [UIView animateWithDuration:animateDelay animations:^{

        btn.transform = CGAffineTransformMakeScale(1.0, 1.0);

    } completion:^(BOOL finished) {

        NSLog(@">>>>>>Abcdef");



    }];

}

字体大小

btnOpenAppURL.titleLabel.font    = [UIFont systemFontOfSize: 12];


关于btn

标签:图片   action   

原文地址:http://10907795.blog.51cto.com/10897795/1864285

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!