酷店

KDPRecommendHeadView.m 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // KDPRecommendHeadView.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/4.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPRecommendHeadView.h"
  9. @implementation KDPRecommendHeadView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self =[super initWithFrame:frame];
  13. if (self) {
  14. UIImageView *backV=[[UIImageView alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH-20, 56)];
  15. backV.backgroundColor=[UIColor whiteColor];
  16. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:backV.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(6, 6)];
  17. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  18. maskLayer.frame = backV.bounds;
  19. maskLayer.path = maskPath.CGPath;
  20. backV.layer.mask = maskLayer;
  21. backV.layer.masksToBounds=YES;
  22. [self addSubview:backV];
  23. UIImageView *bannerImg=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 35)];
  24. bannerImg.center=backV.center;
  25. bannerImg.image=[UIImage imageNamed:@"recommend_icon"];
  26. [backV addSubview:bannerImg];
  27. }
  28. return self;
  29. }
  30. @end