猎豆优选

LDnoticeView.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //
  2. // LDnoticeView.m
  3. // YouHuiProject
  4. //
  5. // Created by liuxueli on 2019/3/6.
  6. // Copyright © 2019 kuxuan. All rights reserved.
  7. //
  8. #import "LDnoticeView.h"
  9. @implementation LDnoticeView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self =[super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor =[UIColor clearColor];
  15. UIView *whiteView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, FITSIZE(250), FITSIZE(294))];
  16. whiteView.backgroundColor=[UIColor whiteColor];
  17. whiteView.centerY =self.centerY;
  18. whiteView.centerX = self.centerX;
  19. whiteView.layer.cornerRadius=8;
  20. whiteView.layer.masksToBounds = YES;
  21. [self addSubview:whiteView];
  22. UIImageView *back_img =[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(78), -FITSIZE(33), FITSIZE(94), FITSIZE(90))];
  23. back_img.centerX = self.centerX;
  24. back_img.top = whiteView.top-FITSIZE(37);
  25. back_img.image =[UIImage imageNamed:@"notice_img"];
  26. [self addSubview:back_img];
  27. UILabel *titlel =[[UILabel alloc]initWithFrame:CGRectMake(0, FITSIZE(71), whiteView.width, FITSIZE(25))];
  28. titlel.textAlignment =NSTextAlignmentCenter;
  29. titlel.text=@"开启消息推送通知";
  30. titlel.font =[UIFont boldSystemFontOfSize:FITSIZE(18)];
  31. titlel.textColor=[UIColor YHColorWithHex:0x333333];
  32. [whiteView addSubview:titlel];
  33. UIButton *oneBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), titlel.bottom+FITSIZE(18), whiteView.width-FITSIZE(56), FITSIZE(20))];
  34. [oneBtn setTitle:@"第一时间掌握优惠商品信息" forState:UIControlStateNormal];
  35. [oneBtn setImage:[UIImage imageNamed:@"notice_yh"] forState:UIControlStateNormal];
  36. [oneBtn setButtonStyle:WSLButtonStyleImageLeft spacing:5];
  37. [oneBtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  38. oneBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(14)];
  39. [whiteView addSubview:oneBtn];
  40. oneBtn.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
  41. UIButton *twoBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), oneBtn.bottom+FITSIZE(13), whiteView.width-FITSIZE(56), FITSIZE(20))];
  42. [twoBtn setTitle:@"实时掌握收益动态" forState:UIControlStateNormal];
  43. [twoBtn setImage:[UIImage imageNamed:@"notice_sy"] forState:UIControlStateNormal];
  44. [twoBtn setButtonStyle:WSLButtonStyleImageLeft spacing:5];
  45. [twoBtn setTitleColor:[UIColor YHColorWithHex:0x333333] forState:UIControlStateNormal];
  46. twoBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(14)];
  47. [whiteView addSubview:twoBtn];
  48. twoBtn.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;
  49. UIButton *openNoticeBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), twoBtn.bottom+FITSIZE(28), whiteView.width-FITSIZE(56), FITSIZE(35))];
  50. [openNoticeBtn setTitle:@"开启通知" forState:UIControlStateNormal];
  51. openNoticeBtn.backgroundColor = [UIColor gradientWidthFromColor:[UIColor YHColorWithHex:0xFA2A37] toColor:[UIColor YHColorWithHex:0xFC7123] withWidth:whiteView.width-FITSIZE(56)];
  52. openNoticeBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(15)];
  53. openNoticeBtn.layer.cornerRadius =6;
  54. openNoticeBtn.layer.masksToBounds=YES;
  55. [openNoticeBtn addTarget:self action:@selector(openNoticeClick) forControlEvents:UIControlEventTouchUpInside];
  56. [whiteView addSubview:openNoticeBtn];
  57. UIButton *closeNoticeBtn =[[UIButton alloc]initWithFrame:CGRectMake(FITSIZE(28), openNoticeBtn.bottom+FITSIZE(14), whiteView.width-FITSIZE(56), FITSIZE(35))];
  58. [closeNoticeBtn setTitle:@"残忍拒绝" forState:UIControlStateNormal];
  59. closeNoticeBtn.backgroundColor = [UIColor colorWithRed:244/255.0 green:244/255.0 blue:244/255.0 alpha:1.0];
  60. closeNoticeBtn.titleLabel.font =[UIFont systemFontOfSize:FITSIZE(15)];
  61. closeNoticeBtn.layer.cornerRadius =6;
  62. closeNoticeBtn.layer.masksToBounds=YES;
  63. [closeNoticeBtn setTitleColor:[UIColor YHColorWithHex:0xB0B0B0] forState:UIControlStateNormal];
  64. [closeNoticeBtn addTarget:self action:@selector(closeNoticeClick) forControlEvents:UIControlEventTouchUpInside];
  65. [whiteView addSubview:closeNoticeBtn];
  66. }
  67. return self;
  68. }
  69. -(void)openNoticeClick
  70. {
  71. if (self.clickBlock) {
  72. self.clickBlock();
  73. }
  74. }
  75. -(void)closeNoticeClick
  76. {
  77. if (self.closeBlock) {
  78. self.closeBlock();
  79. }
  80. }
  81. @end