12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- //
- // TRButton.m
- // jiaPei
- //
- // Created by apple on 15/11/12.
- // Copyright (c) 2015年 JCZ. All rights reserved.
- //
- #import "TRButton.h"
- @interface TRButton()
- {
- /**用于使按钮的图片,每次点击都能旋转。
- */
- NSInteger repeat;
- }
- @end
- @implementation TRButton
- -(id)initWithFrame:(CGRect)frame{
- self = [super initWithFrame:frame];
- // CGFloat wid = frame.size.width;
- // CGFloat hei = frame.size.height;
- if (self) {
- self.backgroundColor = [UIColor whiteColor];
- self.titleLabel.font = [UIFont scaleSize:14];
- self.titleLabel.textAlignment = NSTextAlignmentCenter;
- [self setTitleColor:kTitleColor forState:UIControlStateNormal];
- [self setImage:[UIImage imageNamed:@"location_more_arrow"] forState:UIControlStateNormal];
-
- self.layer.borderWidth = 1;
- self.layer.borderColor = KlineColor.CGColor;
- self.imageView.contentMode = UIViewContentModeScaleAspectFit;
- repeat =1 ;
- }
- return self;
- }
- -(CGRect)titleRectForContentRect:(CGRect)contentRect
- {
- CGFloat w = self.width;
- CGFloat h = self.height;
- return CGRectMake(0, 0, w*.7, h);
- }
- -(CGRect)imageRectForContentRect:(CGRect)contentRect
- {
- CGFloat w = self.width;
- CGFloat h = self.height;
- CGFloat len = 25;
- if ( w*.3 > len) {
- return CGRectMake(w*.7, 0, len, h);
- }
- return CGRectMake( w*.7,0,w*.25, h);
- }
- -(void)makeAnimate{
- [UIView animateWithDuration:.3 animations:^{
- self.imageView.transform = CGAffineTransformMakeRotation( M_PI * (repeat++));
- }];
- }
- -(void)setImgN:(NSString *)imgN
- {
- [self setImage:[UIImage imageNamed:imgN] forState:UIControlStateNormal];
-
- }
- @end
|