weng1250 / WZLBadge

//An one-line tool to show styles of badge for UIView
MIT License
1.78k stars 318 forks source link

Autolayout不能自动更新 #24

Open luyud opened 8 years ago

luyud commented 8 years ago

我的TableViewCell使用xib自动布局, 当xib中的cell高度和代码中不一致时,WZLBadge显示的位置会以xib中的为准,同样的Label使用自动布局时也无法根据文字长度更新badge位置。

zj381652512 commented 5 years ago

// ====================== ZJ添加:修正xib控件显示角标位置不正确问题 ======================

// ====================== end ======================

qy0827a commented 5 years ago

// ====================== ZJ添加:修正xib控件显示角标位置不正确问题 ======================

  • (void)load { [super load]; Method m1 = class_getInstanceMethod(self, @selector(layoutSubviews)); Method m2 = class_getInstanceMethod(self, @selector(zj_layoutSubviews)); method_exchangeImplementations(m1, m2); }

  • (void)zj_layoutSubviews { [self zj_layoutSubviews]; self.badge.center = CGPointMake(CGRectGetWidth(self.frame) + 2 + self.badgeCenterOffset.x, self.badgeCenterOffset.y); }

// ====================== end ======================

这个是写在哪里的?请教大佬