GDButton.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // GDButton.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/11/20.
  6. // Copyright (c) 2015年 JCZ. All rights reserved.
  7. //
  8. #import "GDButton.h"
  9. @implementation GDButton
  10. {
  11. UILabel* subTitle;
  12. }
  13. -(instancetype)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. [self setTitleColor:kTitleColor forState:UIControlStateNormal];
  18. [self.imageView setContentMode:UIViewContentModeScaleAspectFit];
  19. [self.titleLabel setTextAlignment:NSTextAlignmentLeft];
  20. subTitle = [[UILabel alloc] init];
  21. [subTitle setFont:[UIFont scaleSize:13]];
  22. [subTitle setTextColor:contentTextColor];
  23. [self addSubview:subTitle];
  24. }
  25. return self;
  26. }
  27. -(void)setDetailText:(NSString*)str
  28. {
  29. CGFloat hei = self.frame.size.height;
  30. CGFloat wid = self.frame.size.width;
  31. [subTitle setFrame:CGRectMake( wid*.1, hei*.5, wid*.6, hei*.4)];
  32. [subTitle setText:str];
  33. }
  34. -(CGRect)imageRectForContentRect:(CGRect)contentRect
  35. {
  36. CGFloat hei = self.frame.size.height;
  37. CGFloat wid = self.frame.size.width;
  38. return CGRectMake(wid*.75,hei*.1,wid*.15,hei*.8);
  39. }
  40. -(CGRect)titleRectForContentRect:(CGRect)contentRect
  41. {
  42. CGFloat hei = self.frame.size.height;
  43. CGFloat wid = self.frame.size.width;
  44. return CGRectMake( wid*.1, hei*.1, wid*.6, hei*.4);
  45. }
  46. @end
  47. /*
  48. wid . hei
  49. left_bd = wid*.1
  50. right_bd =wid*.1
  51. top_bd = hei*.1
  52. bot_bd = hei*.1
  53. lblw = wid*.6
  54. imgw = wid*.3
  55. lblh = hei*.4
  56. imgh = hei*.8
  57. **/