CustomButton.m 1.2 KB

1234567891011121314151617181920212223242526272829
  1. //
  2. // CustomButton.m
  3. // 自定义Button
  4. //
  5. // Created by sunbk on 16/7/6.
  6. // Copyright © 2016年 xingyuan. All rights reserved.
  7. #import "CustomButton.h"
  8. @implementation CustomButton
  9. - (instancetype)initWithFrame:(CGRect)frame bothLabelHeight:(CGFloat)height imgName:(NSString *)imgName
  10. {
  11. if (self = [super initWithFrame:frame])
  12. {
  13. self.customImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imgName]];
  14. self.customImgView.center = CGPointMake(frame.size.width/2.0, (frame.size.height - height)/2.0);
  15. self.leftLabel = [[UILabel alloc]initWithFrame:CGRectMake(kScreenW *0.0312, frame.size.height-height-kScreenH *0.0176, frame.size.width*0.6, height)];
  16. self.leftLabel.textAlignment = NSTextAlignmentLeft;
  17. self.rightButton = [[UIButton alloc]initWithFrame:CGRectMake(frame.size.width*0.25+kScreenW *0.0312, frame.size.height-height-kScreenH *0.0176,frame.size.width-frame.size.width*0.25-kScreenW *0.0312, height)];
  18. self.rightButton.titleLabel.textAlignment = NSTextAlignmentRight;
  19. [self addSubview:self.customImgView];
  20. [self addSubview:self.leftLabel];
  21. [self addSubview:self.rightButton];
  22. }
  23. return self;
  24. }
  25. @end