git.iko.soy/rowtype-yoga/purescript-yoga-react-native
on main help sign in
Custom drawRect GIF renderer with clipping path for rounded corners
commit7ce930fb57412a3cc4886d8882871c1a8431e529 authorMark <mark.eibes@gmail.com> dateSat 14 Feb 2026, 09:44 (8 months ago) parentc0516e1
1 file changed+18−3
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+18−3
example-macos/macos/YogaReactExample-macOS/RCTMacOSControlsManager.m+18−3
@@ -1633,10 +1633,21 @@ RCT_EXPORT_VIEW_PROPERTY(cornerRadius, CGFloat)
16331633}
16341634
16351635- (void)setupAnimation {
1636− _frameCount = [[_image representations] count];
16371636 _currentFrame = 0;
1637+ _frameCount = 0;
1638+ for (NSImageRep *rep in [_image representations]) {
1639+ if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
1640+ NSBitmapImageRep *bmp = (NSBitmapImageRep *)rep;
1641+ NSNumber *count = [bmp valueForProperty:NSImageFrameCount];
1642+ if (count && [count integerValue] > 1) {
1643+ _frameCount = [count integerValue];
1644+ break;
1645+ }
1646+ }
1647+ }
16381648 if (_frameCount > 1 && _animating) {
16391649 NSBitmapImageRep *rep = (NSBitmapImageRep *)[[_image representations] firstObject];
1650+ [rep setProperty:NSImageCurrentFrame withValue:@(0)];
16401651 NSNumber *delay = [rep valueForProperty:NSImageCurrentFrameDuration];
16411652 CGFloat interval = delay ? [delay doubleValue] : 0.05;
16421653 if (interval < 0.02) interval = 0.05;
@@ -1646,8 +1657,12 @@ RCT_EXPORT_VIEW_PROPERTY(cornerRadius, CGFloat)
16461657
16471658- (void)advanceFrame {
16481659 _currentFrame = (_currentFrame + 1) % _frameCount;
1649− NSBitmapImageRep *rep = (NSBitmapImageRep *)[[_image representations] firstObject];
1650− [rep setProperty:NSImageCurrentFrame withValue:@(_currentFrame)];
1660+ for (NSImageRep *rep in [_image representations]) {
1661+ if ([rep isKindOfClass:[NSBitmapImageRep class]]) {
1662+ [(NSBitmapImageRep *)rep setProperty:NSImageCurrentFrame withValue:@(_currentFrame)];
1663+ break;
1664+ }
1665+ }
16511666 [self setNeedsDisplay:YES];
16521667}
16531668