TwoImgView.m 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //
  2. // TwoImgView.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/9/24.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "TwoImgView.h"
  9. @implementation TwoImgView
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. if (self = [super initWithFrame:frame])
  13. {
  14. [self creatView];
  15. }
  16. return self;
  17. }
  18. - (void)creatView
  19. {
  20. self.headView = [[UIImageView alloc]init];
  21. self.headView.frame = self.bounds;
  22. self.headView.layer.cornerRadius = self.headView.frame.size.width/2;
  23. [self addSubview:self.headView];
  24. self.iconImgView = [[UIImageView alloc]initWithFrame:CGRectMake(self.headView.frame.size.height*2/3, self.headView.frame.size.height*2/3,self.headView.frame.size.height/3,self.headView.frame.size.height/3)];
  25. self.iconImgView.layer.cornerRadius = self.iconImgView.frame.size.width/2;
  26. self.iconImgView.hidden = YES;
  27. [self.headView addSubview:self.iconImgView];
  28. }
  29. - (void)getImgViewWithHeadImgString:(NSString *)headImgString andIconImgView:(NSString *)iconImgView
  30. {
  31. [self.headView sd_setImageWithURL:[NSURL URLWithString:headImgString] placeholderImage:kDefaultPreloadHeadImg];
  32. if (iconImgView.length)
  33. {
  34. self.iconImgView.hidden = NO;
  35. [self.headView sd_setImageWithURL:[NSURL URLWithString:iconImgView]];
  36. }
  37. }
  38. @end