2016-10-12 09:32:40 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2014-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
2016-12-02 11:18:15 -08:00
|
|
|
#import "UIView+Yoga.h"
|
2017-01-08 11:42:43 -08:00
|
|
|
#import "YGLayout+Private.h"
|
2016-10-12 09:32:40 -07:00
|
|
|
#import <objc/runtime.h>
|
|
|
|
|
2017-01-08 11:42:43 -08:00
|
|
|
static const void *kYGYogaAssociatedKey = &kYGYogaAssociatedKey;
|
2016-11-21 10:12:26 -08:00
|
|
|
|
2017-01-08 11:42:43 -08:00
|
|
|
@implementation UIView (YogaKit)
|
2016-11-11 16:38:13 -08:00
|
|
|
|
2017-01-08 11:42:43 -08:00
|
|
|
- (YGLayout *)yoga
|
2016-10-12 09:32:40 -07:00
|
|
|
{
|
2017-01-08 11:42:43 -08:00
|
|
|
YGLayout *yoga = objc_getAssociatedObject(self, kYGYogaAssociatedKey);
|
|
|
|
if (!yoga) {
|
|
|
|
yoga = [[YGLayout alloc] initWithView:self];
|
|
|
|
objc_setAssociatedObject(self, kYGYogaAssociatedKey, yoga, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
2016-11-11 16:38:13 -08:00
|
|
|
}
|
2016-11-17 07:29:33 -08:00
|
|
|
|
2017-01-08 11:42:43 -08:00
|
|
|
return yoga;
|
2016-11-17 07:29:33 -08:00
|
|
|
}
|
|
|
|
|
2016-10-27 12:45:07 -07:00
|
|
|
|
|
|
|
@end
|