iOS:Fix onFrameChangedCallback not functional right

This commit is contained in:
pengfei.zhou
2020-03-28 12:03:35 +08:00
committed by osborn
parent 2f0f0494df
commit 050dfc46ae
4 changed files with 48 additions and 23 deletions

View File

@@ -22,12 +22,12 @@
#import "DoricStackNode.h"
NS_ASSUME_NONNULL_BEGIN
@interface DoricRootView : DoricStackView
@property(nonatomic, strong) void (^frameChangedBlock)(CGSize oldSize, CGSize newSize);
@end
@interface DoricRootNode : DoricStackNode
- (void)setupRootView:(DoricStackView *)view;
@end
NS_ASSUME_NONNULL_END

View File

@@ -22,6 +22,37 @@
#import "DoricRootNode.h"
@interface DoricRootView ()
@property(nonatomic, assign) CGSize currentSize;
@end
@implementation DoricRootView
- (instancetype)init {
if (self = [super init]) {
_currentSize = self.frame.size;
}
return self;
}
- (void)layoutSelf:(CGSize)targetSize {
[super layoutSelf:targetSize];
if (!CGSizeEqualToSize(self.currentSize, targetSize) && self.frameChangedBlock) {
self.frameChangedBlock(self.currentSize, targetSize);
}
self.currentSize = targetSize;
}
- (void)setX:(CGFloat)x {
self.superview.x = x;
}
- (void)setY:(CGFloat)y {
self.superview.y = y;
}
@end
@implementation DoricRootNode
- (void)setupRootView:(DoricStackView *)view {
self.view = view;