fix bug: constraint size not updated for frontsizeadjuster

This commit is contained in:
Luke Zhao 2016-01-27 13:49:00 -08:00
parent f696eb7476
commit 733c65d1eb
3 changed files with 4 additions and 4 deletions

View File

@ -10,6 +10,7 @@
@interface ASTextKitFontSizeAdjuster : NSObject
@property (nonatomic, assign) CGSize constrainedSize;
- (instancetype)initWithContext:(ASTextKitContext *)context
minimumScaleFactor:(CGFloat)minimumScaleFactor

View File

@ -13,7 +13,6 @@
{
__weak ASTextKitContext *_context;
CGFloat _minimumScaleFactor;
CGSize _constrainedSize;
}
- (instancetype)initWithContext:(ASTextKitContext *)context
@ -28,7 +27,6 @@
return self;
}
- (CGSize)sizeForAttributedString:(NSAttributedString *)attrString
{
return [attrString boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)

View File

@ -125,11 +125,12 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
_sizeIsCalculated = NO;
_constrainedSize = constrainedSize;
// If the context isn't created yet, it will be initialized with the appropriate size when next accessed.
if (_context) {
if (_context || _fontSizeAdjuster) {
// If we're updating an existing context, make sure to use the same inset logic used during initialization.
// This codepath allows us to reuse the
CGSize shadowConstrainedSize = [[self shadower] insetSizeWithConstrainedSize:constrainedSize];
_context.constrainedSize = shadowConstrainedSize;
if (_context) _context.constrainedSize = shadowConstrainedSize;
if (_fontSizeAdjuster) _fontSizeAdjuster.constrainedSize = shadowConstrainedSize;
}
}
}