dkahgld

ZBTipeView.m 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // ZBTipeView.m
  3. // ZBProject
  4. //
  5. // Created by 学丽 on 2019/4/9.
  6. // Copyright © 2019 ZB. All rights reserved.
  7. //
  8. #import "ZBTipeView.h"
  9. @implementation ZBTipeView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self =[super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.5];
  15. [self addSubview:self.backV];
  16. [self.backV mas_makeConstraints:^(MASConstraintMaker *make) {
  17. make.width.mas_equalTo(281);
  18. make.height.mas_equalTo(303);
  19. make.centerX.mas_equalTo(self.centerX);
  20. make.centerY.mas_equalTo(self.centerY);
  21. }];
  22. [self.backV addSubview:self.titleLabel];
  23. [self.backV addSubview:self.contentLabel];
  24. [self.backV addSubview:self.okBtn];
  25. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.mas_equalTo(23);
  27. make.height.mas_equalTo(34);
  28. make.left.mas_equalTo(10);
  29. make.right.mas_equalTo(-10);
  30. }];
  31. [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(14);
  33. make.left.mas_equalTo(20);
  34. make.right.mas_equalTo(-20);
  35. }];
  36. [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.mas_equalTo(86);
  38. make.height.mas_equalTo(33);
  39. make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(25);
  40. make.right.mas_equalTo(-85);
  41. }];
  42. }
  43. return self;
  44. }
  45. -(UILabel *)titleLabel
  46. {
  47. if (!_titleLabel ) {
  48. _titleLabel=[[UILabel alloc]init];
  49. _titleLabel.textColor=[UIColor YHColorWithHex:0x333333];
  50. _titleLabel.font=[UIFont boldSystemFontOfSize:18];
  51. _titleLabel.textAlignment=NSTextAlignmentCenter;
  52. _titleLabel.text=@"预估收益";
  53. }
  54. return _titleLabel;
  55. }
  56. -(UIView *)backV
  57. {
  58. if (!_backV) {
  59. _backV =[[UIView alloc]init];
  60. _backV.backgroundColor=[UIColor whiteColor];
  61. _backV.layer.cornerRadius=9;
  62. _backV.layer.masksToBounds=YES;
  63. }
  64. return _backV;
  65. }
  66. -(UILabel *)contentLabel
  67. {
  68. if (!_contentLabel) {
  69. _contentLabel=[[UILabel alloc]init];
  70. _contentLabel.textColor=[UIColor YHColorWithHex:0x333333];
  71. _contentLabel.font=[UIFont systemFontOfSize:15];
  72. _contentLabel.numberOfLines=0;
  73. NSString *str=@"• 总预估收益是指所有已付款订单产生的收益\n• 每月预估算收益是指每个自然月内已付款订单产生的收益\n• 每天预估收益是指每天24小时内已付款订单产生的收益";
  74. NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:str];
  75. NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
  76. [paragraphStyle1 setLineSpacing:8];
  77. [attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, [str length])];
  78. [_contentLabel setAttributedText:attributedString1];
  79. [_contentLabel sizeToFit];
  80. // _contentLabel.text=@"• 总预估收益是指所有已付款订单产生的收益 \n• 每月预估算收益是指每个自然月内已付款订单产生的收益 \n• 每天预估收益是指每天24小时内已付款订单产生的收益";
  81. }
  82. return _contentLabel;
  83. }
  84. -(UIButton *)okBtn
  85. {
  86. if (!_okBtn) {
  87. _okBtn =[[UIButton alloc]init];
  88. [_okBtn setTitleColor:[UIColor baseColor] forState:UIControlStateNormal];
  89. _okBtn.titleLabel.font=[UIFont systemFontOfSize:15];
  90. _okBtn.layer.cornerRadius=8;
  91. _okBtn.layer.masksToBounds=YES;
  92. _okBtn.layer.borderColor=[UIColor baseColor].CGColor;
  93. _okBtn.layer.borderWidth=1;
  94. [_okBtn setTitle:@"知道了" forState:UIControlStateNormal];
  95. _okBtn.layer.cornerRadius=4;
  96. _okBtn.layer.masksToBounds=YES;
  97. [_okBtn addTarget:self action:@selector(clickOpentb) forControlEvents:UIControlEventTouchUpInside];
  98. }
  99. return _okBtn;
  100. }
  101. -(void)clickOpentb
  102. {
  103. self.hidden =YES;
  104. }
  105. @end