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
This commit is contained in:
Bin Yu
2017-09-21 09:58:08 -07:00
committed by Facebook Github Bot
parent d90914f3dc
commit 58328d01ef
2 changed files with 9 additions and 0 deletions

View File

@@ -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`

View File

@@ -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) {