From 58328d01efa7ad30f89761f510ae4131796d7f4a Mon Sep 17 00:00:00 2001 From: Bin Yu Date: Thu, 21 Sep 2017 09:58:08 -0700 Subject: [PATCH] Add 'useYoga' property to indicate whether UIView uses Yoga for layout or not Summary: Now developer could check whether UIView uses Yoga for layout. Reviewed By: emilsjolander Differential Revision: D5881242 fbshipit-source-id: 4d1cf0b489b759ff0b9c5091cc51534fd12dcf60 --- YogaKit/Source/UIView+Yoga.h | 4 ++++ YogaKit/Source/UIView+Yoga.m | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/YogaKit/Source/UIView+Yoga.h b/YogaKit/Source/UIView+Yoga.h index 0dce4993..49f97cd0 100644 --- a/YogaKit/Source/UIView+Yoga.h +++ b/YogaKit/Source/UIView+Yoga.h @@ -20,6 +20,10 @@ typedef void (^YGLayoutConfigurationBlock)(YGLayout *); The YGLayout that is attached to this view. It is lazily created. */ @property (nonatomic, readonly, strong) YGLayout *yoga; +/** + Indicates whether or not Yoga is enabled + */ +@property (nonatomic, readonly, assign) BOOL isYogaEnabled; /** In ObjC land, every time you access `view.yoga.*` you are adding another `objc_msgSend` diff --git a/YogaKit/Source/UIView+Yoga.m b/YogaKit/Source/UIView+Yoga.m index 4448b377..6b8d921b 100644 --- a/YogaKit/Source/UIView+Yoga.m +++ b/YogaKit/Source/UIView+Yoga.m @@ -26,6 +26,11 @@ static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey; return yoga; } +- (BOOL)isYogaEnabled +{ + return objc_getAssociatedObject(self, kYGYogaAssociatedKey) != nil; +} + - (void)configureLayoutWithBlock:(YGLayoutConfigurationBlock)block { if (block != nil) {