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