|
|
@@ -84,59 +84,4 @@
|
|
|
]];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-#pragma mark - Runtime Adjustment
|
|
|
-
|
|
|
-#define PropertyKey(suffix) kFLEXPropertyAttributeKey##suffix : @""
|
|
|
-#define PropertyKeyGetter(getter) kFLEXPropertyAttributeKeyCustomGetter : NSStringFromSelector(@selector(getter))
|
|
|
-#define PropertyKeySetter(setter) kFLEXPropertyAttributeKeyCustomSetter : NSStringFromSelector(@selector(setter))
|
|
|
-
|
|
|
-/// Takes: min iOS version, property name, target class, property type, and a list of attributes
|
|
|
-#define FLEXRuntimeUtilityTryAddProperty(iOS_atLeast, name, cls, type, ...) ({ \
|
|
|
- if (@available(iOS iOS_atLeast, *)) { \
|
|
|
- NSMutableDictionary *attrs = [NSMutableDictionary dictionaryWithDictionary:@{ \
|
|
|
- kFLEXPropertyAttributeKeyTypeEncoding : @(type), \
|
|
|
- __VA_ARGS__ \
|
|
|
- }]; \
|
|
|
- [FLEXRuntimeUtility \
|
|
|
- tryAddPropertyWithName:#name \
|
|
|
- attributes:attrs \
|
|
|
- toClass:[cls class] \
|
|
|
- ]; \
|
|
|
- } \
|
|
|
-})
|
|
|
-
|
|
|
-/// Takes: min iOS version, property name, target class, property type, and a list of attributes
|
|
|
-#define FLEXRuntimeUtilityTryAddNonatomicProperty(iOS_atLeast, name, cls, type, ...) \
|
|
|
- FLEXRuntimeUtilityTryAddProperty(iOS_atLeast, name, cls, @encode(type), PropertyKey(NonAtomic), __VA_ARGS__);
|
|
|
-/// Takes: min iOS version, property name, target class, property type (class name), and a list of attributes
|
|
|
-#define FLEXRuntimeUtilityTryAddObjectProperty(iOS_atLeast, name, cls, type, ...) \
|
|
|
- FLEXRuntimeUtilityTryAddProperty(iOS_atLeast, name, cls, FLEXEncodeClass(type), PropertyKey(NonAtomic), __VA_ARGS__);
|
|
|
-
|
|
|
-+ (void)load {
|
|
|
- // A quirk of UIView and some other classes: a lot of the `@property`s are
|
|
|
- // not actually properties from the perspective of the runtime.
|
|
|
- //
|
|
|
- // We add these properties to the class at runtime if they haven't been added yet.
|
|
|
- // This way, we can use our property editor to access and change them.
|
|
|
- // The property attributes match the declared attributes in their headers.
|
|
|
-
|
|
|
- // UIView, public
|
|
|
- FLEXRuntimeUtilityTryAddNonatomicProperty(2, frame, UIView, CGRect);
|
|
|
- FLEXRuntimeUtilityTryAddNonatomicProperty(2, alpha, UIView, CGFloat);
|
|
|
- FLEXRuntimeUtilityTryAddNonatomicProperty(2, clipsToBounds, UIView, BOOL);
|
|
|
- FLEXRuntimeUtilityTryAddNonatomicProperty(2, opaque, UIView, BOOL, PropertyKeyGetter(isOpaque));
|
|
|
- FLEXRuntimeUtilityTryAddNonatomicProperty(2, hidden, UIView, BOOL, PropertyKeyGetter(isHidden));
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(2, backgroundColor, UIView, UIColor, PropertyKey(Copy));
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(6, constraints, UIView, NSArray, PropertyKey(ReadOnly));
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(2, subviews, UIView, NSArray, PropertyKey(ReadOnly));
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(2, superview, UIView, UIView, PropertyKey(ReadOnly));
|
|
|
-
|
|
|
- // UIButton, private
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(2, font, UIButton, UIFont, PropertyKey(ReadOnly));
|
|
|
-
|
|
|
- // UIViewController, public
|
|
|
- FLEXRuntimeUtilityTryAddObjectProperty(3, toolbarItems, UIViewController, NSArray);
|
|
|
-}
|
|
|
-
|
|
|
@end
|