mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 18:40:05 +00:00
Fix add subviews coordinate bug
This commit is contained in:
parent
40cd431d14
commit
40b51de5fe
@ -20,4 +20,8 @@
|
||||
toLayerNamed:(nonnull NSString *)layerName
|
||||
applyTransform:(BOOL)applyTransform;
|
||||
|
||||
- (CGRect)convertRect:(CGRect)rect
|
||||
fromLayer:(CALayer *_Nonnull)fromlayer
|
||||
toLayerNamed:(NSString *_Nonnull)layerName;
|
||||
|
||||
@end
|
||||
|
@ -137,6 +137,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (CGRect)convertRect:(CGRect)rect
|
||||
fromLayer:(CALayer *_Nonnull)fromlayer
|
||||
toLayerNamed:(NSString *_Nonnull)layerName {
|
||||
CGRect xRect = rect;
|
||||
for (LOTLayerContainer *child in _childLayers) {
|
||||
if ([child.layerName isEqualToString:layerName]) {
|
||||
xRect = [fromlayer convertRect:rect toLayer:child];
|
||||
}
|
||||
}
|
||||
return xRect;
|
||||
}
|
||||
|
||||
- (void)setViewportBounds:(CGRect)viewportBounds {
|
||||
[super setViewportBounds:viewportBounds];
|
||||
for (LOTLayerContainer *layer in _childLayers) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
#import "LOTMaskContainer.h"
|
||||
#import "LOTAsset.h"
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
#import "LOTCacheProvider.h"
|
||||
#endif
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
[_wrapperLayer addSublayer:_contentsGroup.containerLayer];
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
- (void)_setImageForAsset:(LOTAsset *)asset {
|
||||
if (asset.imageName) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import "CALayer+Compat.h"
|
||||
|
||||
@implementation CALayer (Compat)
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#import "TargetConditionals.h"
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSValue (Compat)
|
||||
|
@ -3,7 +3,7 @@
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import "NSValue+Compat.h"
|
||||
|
||||
@implementation NSValue (Compat)
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreGraphics/CoreGraphics.h>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright © 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
#import "UIColor.h"
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
|
@ -59,18 +59,19 @@
|
||||
toSnapshot.frame = containerView.bounds;
|
||||
|
||||
UIView *fromSnapshot = [fromVC.view resizableSnapshotViewFromRect:containerView.bounds
|
||||
afterScreenUpdates:YES
|
||||
afterScreenUpdates:NO
|
||||
withCapInsets:UIEdgeInsetsZero];
|
||||
fromSnapshot.frame = containerView.bounds;
|
||||
|
||||
tranistionAnimationView_.frame = containerView.bounds;
|
||||
tranistionAnimationView_.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[containerView addSubview:tranistionAnimationView_];
|
||||
tranistionAnimationView_.animationProgress = 0;
|
||||
[tranistionAnimationView_ layoutSubviews];
|
||||
|
||||
BOOL crossFadeViews = NO;
|
||||
|
||||
if (toLayerName_.length) {
|
||||
CGRect convertedBounds = [tranistionAnimationView_ convertRect:containerView.bounds toLayerNamed:toLayerName_];
|
||||
toSnapshot.frame = convertedBounds;
|
||||
[tranistionAnimationView_ addSubview:toSnapshot toLayerNamed:toLayerName_ applyTransform:_applyTransform];
|
||||
} else {
|
||||
[containerView addSubview:toSnapshot];
|
||||
@ -80,6 +81,8 @@
|
||||
}
|
||||
|
||||
if (fromLayerName_.length) {
|
||||
CGRect convertedBounds = [tranistionAnimationView_ convertRect:containerView.bounds toLayerNamed:fromLayerName_];
|
||||
fromSnapshot.frame = convertedBounds;
|
||||
[tranistionAnimationView_ addSubview:fromSnapshot toLayerNamed:fromLayerName_ applyTransform:_applyTransform];
|
||||
} else {
|
||||
[containerView addSubview:fromSnapshot];
|
||||
|
@ -141,7 +141,7 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
||||
|
||||
# pragma mark - Internal Methods
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
- (void)_initializeAnimationContainer {
|
||||
self.clipsToBounds = YES;
|
||||
@ -417,11 +417,12 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
||||
|
||||
# pragma mark - External Methods - Other
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
- (void)addSubview:(nonnull LOTView *)view
|
||||
toLayerNamed:(nonnull NSString *)layer
|
||||
applyTransform:(BOOL)applyTransform {
|
||||
[self _layout];
|
||||
CGRect viewRect = view.frame;
|
||||
LOTView *wrapperView = [[LOTView alloc] initWithFrame:viewRect];
|
||||
view.frame = view.bounds;
|
||||
@ -429,9 +430,6 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
||||
[wrapperView addSubview:view];
|
||||
[self addSubview:wrapperView];
|
||||
[_compContainer addSublayer:wrapperView.layer toLayerNamed:layer applyTransform:applyTransform];
|
||||
CGRect newRect = [self.layer convertRect:viewRect toLayer:wrapperView.layer.superlayer];
|
||||
wrapperView.layer.frame = newRect;
|
||||
view.frame = newRect;
|
||||
}
|
||||
|
||||
#else
|
||||
@ -446,12 +444,18 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
||||
[wrapperView addSubview:view];
|
||||
[self addSubview:wrapperView];
|
||||
[_compContainer addSublayer:wrapperView.layer toLayerNamed:layer applyTransform:applyTransform];
|
||||
CGRect newRect = [self.layer convertRect:viewRect toLayer:wrapperView.layer.superlayer];
|
||||
wrapperView.layer.frame = newRect;
|
||||
view.frame = newRect;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
- (CGRect)convertRect:(CGRect)rect
|
||||
toLayerNamed:(NSString *_Nonnull)layerName {
|
||||
[self _layout];
|
||||
return [_compContainer convertRect:rect fromLayer:self.layer toLayerNamed:layerName];
|
||||
}
|
||||
|
||||
|
||||
- (void)setValue:(nonnull id)value
|
||||
forKeypath:(nonnull NSString *)keypath
|
||||
atFrame:(nullable NSNumber *)frame{
|
||||
@ -494,7 +498,7 @@ static NSString * const kCompContainerAnimationKey = @"play";
|
||||
|
||||
# pragma mark - Overrides
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
#define LOTViewContentMode UIViewContentMode
|
||||
#define LOTViewContentModeScaleToFill UIViewContentModeScaleToFill
|
||||
|
@ -162,7 +162,18 @@ typedef void (^LOTAnimationCompletionBlock)(BOOL animationFinished);
|
||||
toLayerNamed:(nonnull NSString *)layer
|
||||
applyTransform:(BOOL)applyTransform;
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
|
||||
/**
|
||||
* Converts the given CGRect from the recieving animation view's coordinate space
|
||||
* to the supplied layer's coordinate space
|
||||
*
|
||||
* This is helpful when adding custom subviews to a LOTAnimationView
|
||||
*
|
||||
**/
|
||||
|
||||
- (CGRect)convertRect:(CGRect)rect
|
||||
toLayerNamed:(NSString *_Nonnull)layerName;
|
||||
|
||||
#if !TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR
|
||||
@property (nonatomic) LOTViewContentMode contentMode;
|
||||
#endif
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// Copyright (c) 2017 Airbnb. All rights reserved.
|
||||
//
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@compatibility_alias LOTView UIView;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@compatibility_alias LOTImage UIImage;
|
||||
|
@ -23,11 +23,11 @@ FOUNDATION_EXPORT const unsigned char LottieVersionString[];
|
||||
|
||||
#include <TargetConditionals.h>
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
#import "LOTAnimationTransitionController.h"
|
||||
#endif
|
||||
|
||||
#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
|
||||
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
|
||||
#import "LOTCacheProvider.h"
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user