MGNewDTNavView.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // MGNewDTNavView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2019/11/26.
  6. // Copyright © 2019 xfg. All rights reserved.
  7. //
  8. #import "MGNewDTNavView.h"
  9. @implementation MGNewDTNavView
  10. - (instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. [self setUpView];
  15. }
  16. return self;
  17. }
  18. -(void)setUpView{
  19. UIImageView *bgImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kRealValue(175))];
  20. bgImgView.userInteractionEnabled = YES;
  21. bgImgView.image = [UIImage imageNamed:@"mg_hm_topBgImgView"];
  22. [self addSubview:bgImgView];
  23. _chatBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  24. _chatBtn.frame = CGRectMake(kRealValue(10), MG_TOP_MARGIN + kRealValue(10), kRealValue(22), kRealValue(22));
  25. [_chatBtn setImage:[UIImage imageNamed:@"dy_msg"] forState:UIControlStateNormal];
  26. [_chatBtn addTarget:self action:@selector(handleMsgEvent) forControlEvents:UIControlEventTouchUpInside];
  27. self.jsbadge = [[JSBadgeView alloc]initWithParentView:_chatBtn alignment:JSBadgeViewAlignmentTopRight];
  28. //没有反光面
  29. self.jsbadge.badgeOverlayColor = [UIColor clearColor];
  30. //5、外圈的颜色,默认是白色
  31. self.jsbadge.badgeStrokeColor = [UIColor redColor];
  32. self.jsbadge.badgeShadowColor = [UIColor clearColor];
  33. // _searchBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  34. // _searchBtn.frame = CGRectMake(_chatBtn.right + kRealValue(15), 0, kRealValue(220), kRealValue(32));
  35. // _searchBtn.centerY = _chatBtn.centerY;
  36. // _searchBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  37. // [_searchBtn setTitle:ASLocalizedString(@"搜索")forState:UIControlStateNormal];
  38. // _searchBtn.backgroundColor = [UIColor colorWithHexString:@"#F5F5F5"];
  39. // [_searchBtn setTitleColor:[UIColor colorWithHexString:@"#999999"] forState:UIControlStateNormal];
  40. // [_searchBtn setImage:[UIImage imageNamed:@"fw_me_search"] forState:UIControlStateNormal];
  41. // _searchBtn.layer.cornerRadius = kRealValue(32 / 2);
  42. // [_searchBtn addTarget:self action:@selector(handleTouchSearch) forControlEvents:UIControlEventTouchUpInside];
  43. // _searchBtn.layer.masksToBounds = YES;
  44. // _searchBtn.titleLabel.font = [UIFont systemFontOfSize:16];
  45. QMUIButton *searchBTN = [QMUIButton buttonWithType:UIButtonTypeCustom];
  46. searchBTN.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  47. [searchBTN setImage:[UIImage imageNamed:@"hm_search_btn"] forState:UIControlStateNormal];
  48. searchBTN.frame = CGRectMake(_chatBtn.right + kRealValue(20),MG_TOP_MARGIN,kScreenW - kRealValue(88) - kRealValue(55),kRealValue(30));
  49. [searchBTN addTarget:self action:@selector(handleTouchSearch) forControlEvents:UIControlEventTouchUpInside];
  50. searchBTN.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0);
  51. [searchBTN setTitle:ASLocalizedString(@"搜索")forState:UIControlStateNormal];
  52. searchBTN.titleLabel.font = [UIFont systemFontOfSize:15];
  53. searchBTN.backgroundColor = kClearColor;
  54. [searchBTN setBackgroundImage:[UIImage imageNamed:@"hm_search_btn_bgimgView"]];
  55. // [UIColor colorWithRed:255 green:255 blue:255 alpha:0.6];
  56. searchBTN.layer.cornerRadius = kRealValue(30 / 2);
  57. searchBTN.layer.masksToBounds = YES;
  58. searchBTN.spacingBetweenImageAndTitle = 5;
  59. searchBTN.imagePosition = QMUIButtonImagePositionLeft;
  60. [searchBTN setTitleColor:kWhiteColor forState:UIControlStateNormal];
  61. [self addSubview:searchBTN];
  62. _postBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
  63. _postBtn.frame = CGRectMake(kScreenW - kRealValue(58) - kRealValue(10), MG_TOP_MARGIN, kRealValue(58), kRealValue(30));
  64. _postBtn.centerY = _chatBtn.centerY;
  65. [_postBtn setTitle:ASLocalizedString(@"发帖")forState:UIControlStateNormal];
  66. [_postBtn setTitleColor:[UIColor colorWithHexString:@"#CD49FF"] forState:UIControlStateNormal];
  67. _postBtn.layer.cornerRadius = kRealValue(32 / 2);
  68. _postBtn.layer.masksToBounds = YES;
  69. _postBtn.titleLabel.font = [UIFont systemFontOfSize:15];
  70. [_postBtn setBackgroundColor:kWhiteColor];
  71. [_postBtn addTarget:self action:@selector(handlePostEvent) forControlEvents:UIControlEventTouchUpInside];
  72. _postBtn.centerY = searchBTN.centerY = _chatBtn.centerY;
  73. [self addSubview:_chatBtn];
  74. [self addSubview:_searchBtn];
  75. [self addSubview:_postBtn];
  76. }
  77. -(void)handleMsgEvent{
  78. if (self.clickPostBlock) {
  79. self.clickPostBlock(2);
  80. }
  81. }
  82. //跳转发帖
  83. -(void)handlePostEvent{
  84. if (self.clickPostBlock) {
  85. self.clickPostBlock(1);
  86. }
  87. }
  88. //跳转话题搜索
  89. -(void)handleTouchSearch{
  90. if (self.clickPostBlock) {
  91. self.clickPostBlock(0);
  92. }
  93. }
  94. @end