KNTableViewCell.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // KNTableViewCell.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 10/8/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "KNTableViewCell.h"
  9. @interface KNTableViewCell () {
  10. BOOL _isNotFirstLoading;
  11. }
  12. @end
  13. @implementation KNTableViewCell
  14. - (void)drawRect:(CGRect)rect {
  15. [super drawRect:rect];
  16. if (!self.superview) {
  17. return;
  18. }
  19. if (!_isNotFirstLoading) {
  20. _isNotFirstLoading = YES;
  21. self.selectionStyle = UITableViewCellSelectionStyleNone;
  22. for (NSLayoutConstraint *constraint in self.contentView.constraints) {
  23. // NSLog(@"%s\n %@", __PRETTY_FUNCTION__, constraint);
  24. if (constraint.firstAttribute == NSLayoutAttributeLeading || constraint.firstAttribute == NSLayoutAttributeTrailing) {
  25. if ([constraint.firstItem isEqual:self.contentView] || [constraint.secondItem isEqual:self.contentView]) {
  26. CGFloat constant = constraint.constant;
  27. if (constraint.constant == 10.0f || constraint.constant == 12.0f || constraint.constant == 15.0f || constraint.constant == 27.0f || constraint.constant == 28.0f || constraint.constant == 30.0f) {
  28. if (IPHONE_WIDTH == 414.0f) {//아이폰 6p일 경우,
  29. constant = constant + 20.0f;
  30. } else if (IPHONE_WIDTH == 375.0f) {//아이폰 6일경우
  31. constant = constant + 10.0f;
  32. }
  33. }
  34. constraint.constant = constant;
  35. }
  36. }
  37. }
  38. }
  39. }
  40. @end
  41. @interface KNTableViewCell2 () {
  42. BOOL _isNotFirstLoading;
  43. }
  44. @end
  45. @implementation KNTableViewCell2
  46. - (void)drawRect:(CGRect)rect {
  47. // [super drawRect:rect];
  48. if (!self.superview) {
  49. return;
  50. }
  51. // Initialization code
  52. // BOOL isHeader = [self isKindOfClass:[NSClassFromString(@"RulesConditionFooterTableViewCell") class]]; //for debug
  53. if (!_isNotFirstLoading) {
  54. _isNotFirstLoading = YES;
  55. self.selectionStyle = UITableViewCellSelectionStyleNone;
  56. for (NSLayoutConstraint *constraint in self.contentView.constraints) {
  57. if (constraint.firstAttribute == NSLayoutAttributeLeading || constraint.firstAttribute == NSLayoutAttributeTrailing) {
  58. if ([constraint.firstItem isEqual:self.contentView] || [constraint.secondItem isEqual:self.contentView]) {
  59. CGFloat constant = constraint.constant;
  60. if (constraint.constant == 10.0f || constraint.constant == 12.0f || constraint.constant == 15.0f || constraint.constant == 27.0f || constraint.constant == 28.0f || constraint.constant == 30.0f) {
  61. if (IPHONE_WIDTH == 414.0f) {//아이폰 6p일 경우,
  62. constant = constant + 10.0f;
  63. } else if (IPHONE_WIDTH == 375.0f) {//아이폰 6일경우
  64. constant = constant + 5.0f;
  65. }
  66. }
  67. constraint.constant = constant;
  68. }
  69. }
  70. }
  71. }
  72. }
  73. @end