BGNoContentView.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // BGNoContentView.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/8/29.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGNoContentView.h"
  9. @implementation BGNoContentView
  10. + (instancetype)noContentWithFrame:(CGRect)frame
  11. {
  12. BGNoContentView *tmpView = [[[NSBundle mainBundle] loadNibNamed:@"BGNoContentView" owner:self options:nil] lastObject];
  13. tmpView.userInteractionEnabled = NO;
  14. tmpView.frame = frame;
  15. return tmpView;
  16. }
  17. - (instancetype)initWithFrame:(CGRect)frame
  18. {
  19. self = [super initWithFrame:frame];
  20. if (self)
  21. {
  22. [self creatMyUI];
  23. }
  24. return self;
  25. }
  26. - (void)awakeFromNib
  27. {
  28. [super awakeFromNib];
  29. for (UIView *subView in self.subviews) {
  30. [subView setLocalizedString];
  31. }
  32. }
  33. - (void)creatMyUI
  34. {
  35. for (UIView *subView in self.subviews) {
  36. [subView setLocalizedString];
  37. }
  38. UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 150)];
  39. imageView.image = [UIImage imageNamed:@"com_no_content"];
  40. [self addSubview:imageView];
  41. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(imageView.frame), 150, 25)];
  42. label.text = ASLocalizedString(@"暂无数据");
  43. label.textAlignment = NSTextAlignmentCenter;
  44. label.font = [UIFont systemFontOfSize:13];
  45. label.textColor = kLightGrayColor;
  46. [self addSubview:label];
  47. }
  48. @end