Merge branch 'charlesmchen/shapeLayerAnimations'
This commit is contained in:
commit
aedeca03dd
@ -85,19 +85,21 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
// Don't fill the shape layer; we just want a stroke around the border.
|
||||
self.shapeLayer.fillColor = [UIColor clearColor].CGColor;
|
||||
|
||||
[CATransaction commit];
|
||||
|
||||
self.clipsToBounds = YES;
|
||||
|
||||
if (!self.bubbleView) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.shapeLayer.strokeColor = self.strokeColor.CGColor;
|
||||
self.shapeLayer.lineWidth = self.strokeThickness;
|
||||
self.shapeLayer.zPosition = 100.f;
|
||||
|
||||
UIBezierPath *bezierPath = [UIBezierPath new];
|
||||
|
||||
UIBezierPath *boundsBezierPath = [UIBezierPath bezierPathWithRect:self.bounds];
|
||||
@ -110,7 +112,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[bubbleBezierPath applyTransform:transform];
|
||||
[bezierPath appendPath:bubbleBezierPath];
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
self.shapeLayer.strokeColor = self.strokeColor.CGColor;
|
||||
self.shapeLayer.lineWidth = self.strokeThickness;
|
||||
self.shapeLayer.zPosition = 100.f;
|
||||
self.shapeLayer.path = bezierPath.CGPath;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -130,7 +130,14 @@ const CGFloat kBubbleTextVInset = 10.f;
|
||||
if (!self.shapeLayer) {
|
||||
[self updateLayers];
|
||||
}
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
self.shapeLayer.fillColor = bubbleColor.CGColor;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (void)updateLayers
|
||||
@ -144,9 +151,15 @@ const CGFloat kBubbleTextVInset = 10.f;
|
||||
|
||||
UIBezierPath *bezierPath = [self maskPath];
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
self.shapeLayer.fillColor = self.bubbleColor.CGColor;
|
||||
self.shapeLayer.path = bezierPath.CGPath;
|
||||
self.maskLayer.path = bezierPath.CGPath;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (UIBezierPath *)maskPath
|
||||
|
||||
@ -73,6 +73,10 @@ import SignalServiceKit
|
||||
internal func updateContent() {
|
||||
SwiftAssertIsOnMainThread(#function)
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
|
||||
let horizontalBarPath = UIBezierPath()
|
||||
let horizontalBarHeightFraction = CGFloat(0.25)
|
||||
let horizontalBarHeight = bounds.size.height * horizontalBarHeightFraction
|
||||
@ -89,5 +93,7 @@ import SignalServiceKit
|
||||
progressPath.append(UIBezierPath(roundedRect: progressBounds, cornerRadius: progressCornerRadius))
|
||||
progressLayer.path = progressPath.cgPath
|
||||
progressLayer.fillColor = progressColor.cgColor
|
||||
|
||||
CATransaction.commit()
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,12 +84,18 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[layer removeFromSuperlayer];
|
||||
}
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
for (ConfigureShapeLayerBlock configureShapeLayerBlock in self.configureShapeLayerBlocks) {
|
||||
CAShapeLayer *shapeLayer = [CAShapeLayer new];
|
||||
configureShapeLayerBlock(shapeLayer, self.bounds);
|
||||
[self.layer addSublayer:shapeLayer];
|
||||
}
|
||||
|
||||
[CATransaction commit];
|
||||
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSProgressView.h"
|
||||
@ -43,6 +43,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.color = [UIColor whiteColor];
|
||||
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
self.borderLayer = [CAShapeLayer new];
|
||||
self.borderLayer.fillColor = self.color.CGColor;
|
||||
[self.layer addSublayer:self.borderLayer];
|
||||
@ -51,6 +55,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
self.progressLayer.fillColor = self.color.CGColor;
|
||||
[self.layer addSublayer:self.progressLayer];
|
||||
|
||||
[CATransaction commit];
|
||||
|
||||
[self setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical];
|
||||
[self setContentHuggingPriority:UILayoutPriorityDefaultHigh forAxis:UILayoutConstraintAxisVertical];
|
||||
}
|
||||
@ -79,6 +85,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)update
|
||||
{
|
||||
// Prevent the shape layer from animating changes.
|
||||
[CATransaction begin];
|
||||
[CATransaction setDisableActions:YES];
|
||||
|
||||
CGFloat kBorderThickness = self.bounds.size.height * 0.1f;
|
||||
CGFloat kOuterRadius = self.bounds.size.height * 0.25f;
|
||||
CGFloat kInnerRadius = kOuterRadius - kBorderThickness;
|
||||
@ -107,6 +117,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
self.progressLayer.path = progressPath.CGPath;
|
||||
self.progressLayer.fillColor = self.color.CGColor;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size
|
||||
|
||||
Loading…
Reference in New Issue
Block a user