JXSearchMoreCell.m 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // JXSearchMoreCell.m
  3. // shiku_im
  4. //
  5. // Created by IMAC on 2019/8/30.
  6. // Copyright © 2019 Reese. All rights reserved.
  7. //
  8. #import "JXSearchMoreCell.h"
  9. @implementation JXSearchMoreCell
  10. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. self.baseView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
  14. self.baseView.backgroundColor = [UIColor clearColor];
  15. self.ImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 7.5, 14, 15)];
  16. [self.baseView addSubview:self.ImgView];
  17. self.moreLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, 80, 10)];
  18. self.moreLable.textColor = HEXCOLOR(0x55BEB8);
  19. self.moreLable.font = [UIFont systemFontOfSize:13];
  20. self.moreLable.numberOfLines = 0;
  21. [self.baseView addSubview:self.moreLable];
  22. [self.contentView addSubview:self.baseView];
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. self.selectView = [[UIView alloc] initWithFrame:CGRectMake(8, 0, JX_SCREEN_WIDTH - 16, 50)];
  25. self.selectView.backgroundColor = [UIColor clearColor];
  26. [self.contentView addSubview:self.selectView];
  27. self.selectView.hidden = YES;
  28. [self cutSelectedView];
  29. }
  30. return self;
  31. }
  32. - (void)setImgName:(NSString *)imgName{
  33. _imgName = imgName;
  34. self.ImgView.image = [UIImage imageNamed:_imgName];
  35. }
  36. - (void)setMoreName:(NSString *)moreName{
  37. _moreName = moreName;
  38. self.moreLable.text = _moreName;
  39. CGSize labelsize = [self.moreLable.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13],NSFontAttributeName,nil]];
  40. self.moreLable.frame = CGRectMake(CGRectGetMaxX(self.ImgView.frame) + 10, (self.baseView.frame.size.height - labelsize.height) / 2, labelsize.width, labelsize.height);
  41. self.baseView.frame = CGRectMake(0, 0, 44 + labelsize.width, 30);
  42. self.baseView.center = CGPointMake(self.center.x + 25, 25);
  43. }
  44. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  45. [super setSelected:selected animated:animated];
  46. if (selected) {
  47. self.selectView.hidden = NO;
  48. [self performSelector:@selector(hiddenSelectView) withObject:nil afterDelay:0.5];
  49. }
  50. }
  51. - (void)cutSelectedView{
  52. CAShapeLayer *layer = [[CAShapeLayer alloc] init];
  53. CGMutablePathRef pathRef = CGPathCreateMutable();
  54. CGRect bounds = CGRectInset(self.selectView.bounds, 0, 0);
  55. CGFloat cornerRadius = 7;
  56. CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
  57. CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
  58. CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
  59. CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
  60. layer.path = pathRef;
  61. CFRelease(pathRef);
  62. layer.fillColor = [UIColor grayColor].CGColor;
  63. [self.selectView.layer addSublayer:layer];
  64. self.selectView.alpha = 0.3;
  65. }
  66. - (void)hiddenSelectView{
  67. self.selectView.hidden = YES;
  68. }
  69. @end