@@ -123,6 +123,7 @@ - (void)draw {
123123 [textLayer setString: self .dynamicTexts[sprite.imageKey]];
124124 textLayer.frame = CGRectMake (0 , 0 , size.width , size.height );
125125 [contentLayer addSublayer: textLayer];
126+ contentLayer.textLayer = textLayer;
126127 }
127128 }
128129 }];
@@ -297,6 +298,24 @@ - (void)setAttributedText:(NSAttributedString *)attributedText forKey:(NSString
297298 NSMutableDictionary *mutableDynamicTexts = [self .dynamicTexts mutableCopy ];
298299 [mutableDynamicTexts setObject: attributedText forKey: aKey];
299300 self.dynamicTexts = mutableDynamicTexts;
301+ if (self.drawLayer .sublayers .count > 0 ) {
302+ CGSize size = [attributedText boundingRectWithSize: CGSizeMake (CGFLOAT_MAX, CGFLOAT_MAX) options: NSStringDrawingUsesLineFragmentOrigin context: NULL ].size ;
303+ CATextLayer *textLayer;
304+ for (SVGAContentLayer *layer in self.drawLayer .sublayers ) {
305+ if ([layer isKindOfClass: [SVGAContentLayer class ]] && [layer.imageKey isEqualToString: aKey]) {
306+ textLayer = layer.textLayer ;
307+ if (textLayer == nil ) {
308+ textLayer = [CATextLayer layer ];
309+ [layer addSublayer: textLayer];
310+ }
311+ }
312+ }
313+ if (textLayer != nil ) {
314+ textLayer.contentsScale = [[UIScreen mainScreen ] scale ];
315+ [textLayer setString: attributedText];
316+ textLayer.frame = CGRectMake (0 , 0 , size.width , size.height );
317+ }
318+ }
300319}
301320
302321- (void )clearDynamicObjects {
0 commit comments