Skip to content
Permalink
Browse files

3.2.0

  • Loading branch information...
MoLice committed May 10, 2019
1 parent 887b6eb commit 49804c263891d86957b9ef323b624fabceee2781
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QMUIKit"
s.version = "3.1.9"
s.version = "3.2.0"
s.summary = "致力于提高项目 UI 开发效率的解决方案"
s.description = <<-DESC
QMUI iOS 是一个致力于提高项目 UI 开发效率的解决方案,其设计目的是用于辅助快速搭建一个具备基本设计还原效果的 iOS 项目,同时利用自身提供的丰富控件及兼容处理, 让开发者能专注于业务需求而无需耗费精力在基础代码的设计上。不管是新项目的创建,或是已有项目的维护,均可使开发效率和项目质量得到大幅度提升。
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.9</string>
<string>3.2.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
@@ -69,20 +69,4 @@ - (BOOL)touchesShouldCancelInContentView:(UIView *)view {
return YES;
}

#ifdef DEBUG

- (void)setContentOffset:(CGPoint)contentOffset {
[super setContentOffset:contentOffset];
}

- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated {
[super setContentOffset:contentOffset animated:animated];
}

- (void)setContentInset:(UIEdgeInsets)contentInset {
[super setContentInset:contentInset];
}

#endif

@end
@@ -339,7 +339,7 @@ + (BOOL)isNotchedScreen {
*/
SEL peripheryInsetsSelector = NSSelectorFromString([NSString stringWithFormat:@"_%@%@", @"periphery", @"Insets"]);
UIEdgeInsets peripheryInsets = UIEdgeInsetsZero;
[[UIScreen mainScreen] qmui_performSelector:peripheryInsetsSelector withReturnValue:&peripheryInsets];
[[UIScreen mainScreen] qmui_performSelector:peripheryInsetsSelector withPrimitiveReturnValue:&peripheryInsets];
if (peripheryInsets.bottom <= 0) {
UIWindow *window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
peripheryInsets = window.safeAreaInsets;
@@ -13,7 +13,7 @@
#ifndef QMUIKit_h
#define QMUIKit_h

static NSString * const QMUI_VERSION = @"3.1.9";
static NSString * const QMUI_VERSION = @"3.2.0";

#if __has_include("CAAnimation+QMUI.h")
#import "CAAnimation+QMUI.h"
@@ -8,12 +8,14 @@

#import "NSMethodSignature+QMUI.h"
#import "NSObject+QMUI.h"
#import "QMUICore.h"

@implementation NSMethodSignature (QMUI)

- (NSString *)qmui_typeString {
NSString *typeString;
[self qmui_performSelector:NSSelectorFromString([NSString stringWithFormat:@"_%@String", @"type"]) withReturnValue:&typeString];
BeginIgnorePerformSelectorLeaksWarning
NSString *typeString = [self performSelector:NSSelectorFromString([NSString stringWithFormat:@"_%@String", @"type"])];
EndIgnorePerformSelectorLeaksWarning
return typeString;
}

@@ -56,40 +56,47 @@
- (id)qmui_performSelectorToSuperclass:(SEL)aSelector withObject:(id)object;

/**
* 系统的 performSelector 不支持参数或返回值为非对象的 selector 的调用,所以在 QMUI 增加了对应的方法,支持对象和非对象的 selector。
* 这个方法用于无参数无返回值的 selector 调用。
* 调用一个无参数、返回值类型为非对象的 selector。如果返回值类型为对象,请直接使用系统的 performSelector: 方法。
* @param selector 要被调用的方法名
* @param returnValue selector 的返回值的指针地址,请先定义一个变量再将其指针地址传进来,例如 &result
*
* @code
* CGFloat alpha;
* [view qmui_performSelector:@selector(alpha) withPrimitiveReturnValue:&alpha];
* @endcode
*/
- (void)qmui_performSelector:(SEL)selector;

/**
* 系统的 performSelector 不支持参数或返回值为非对象的 selector 的调用,所以在 QMUI 增加了对应的方法,支持对象和非对象的 selector。
* @param selector 要被调用的方法名
* @param returnValue selector 的返回值的指针地址
*/
- (void)qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue;
- (void)qmui_performSelector:(SEL)selector withPrimitiveReturnValue:(void *)returnValue;

/**
* 系统的 performSelector 不支持参数或返回值为非对象的 selector 的调用,所以在 QMUI 增加了对应的方法,支持对象和非对象的 selector
* 调用一个带参数的 selector,参数类型支持对象和非对象,也没有数量限制。返回值为对象或者 void
* @param selector 要被调用的方法名
* @param firstArgument 调用 selector 时要传的第一个参数的指针地址,例如 &xxx
* @param firstArgument 参数列表,请传参数的指针地址,支持多个参数
* @return 方法的返回值,如果该方法返回类型为 void,则会返回 nil,如果返回类型为对象,则返回该对象。
*
* @code
* id target = xxx;
* SEL action = xxx;
* UIControlEvents events = xxx;
* [control qmui_performSelector:@selector(addTarget:action:forControlEvents:) withArguments:&target, &action, &events, nil];
* @endcode
*/
- (void)qmui_performSelector:(SEL)selector withArguments:(void *)firstArgument, ...;
- (id)qmui_performSelector:(SEL)selector withArguments:(void *)firstArgument, ...;

/**
* 系统的 performSelector 不支持参数或返回值为非对象的 selector 的调用,所以在 QMUI 增加了对应的方法,支持对象和非对象的 selector。
*
* 使用示例:
* CGFloat result;
* CGFloat arg1, arg2;
* [self qmui_performSelector:xxx withReturnValue:&result arguments:&arg1, &arg2, nil];
* // 到这里 result 已经被赋值为 selector 的 return 值
* 调用一个返回值类型为非对象且带参数的 selector,参数类型支持对象和非对象,也没有数量限制。
*
* @param selector 要被调用的方法名
* @param returnValue selector 的返回值的指针地址
* @param firstArgument 调用 selector 时要传的第一个参数的指针地址
*/
- (void)qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue arguments:(void *)firstArgument, ...;
* @param firstArgument 参数列表,请传参数的指针地址,支持多个参数
*
* @code
* CGPoint point = xxx;
* UIEvent *event = xxx;
* BOOL isInside;
* [view qmui_performSelector:@selector(pointInside:withEvent:) withPrimitiveReturnValue:&isInside arguments:&point, &event, nil];
* @endcode
*/
- (void)qmui_performSelector:(SEL)selector withPrimitiveReturnValue:(void *)returnValue arguments:(void *)firstArgument, ...;


/**
@@ -58,34 +58,48 @@ - (id)qmui_performSelectorToSuperclass:(SEL)aSelector withObject:(id)object {
return (*objc_superAllocTyped)(&mySuper, aSelector, object);
}

- (void)qmui_performSelector:(SEL)selector {
[self qmui_performSelector:selector withReturnValue:NULL arguments:NULL];
}

- (void)qmui_performSelector:(SEL)selector withArguments:(void *)firstArgument, ... {
va_list valist;
va_start(valist, firstArgument);
[self _qmui_performSelector:selector withReturnValue:nil firstArgument:firstArgument otherArguments:valist];
va_end(valist);
}

- (void)qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue {
[self qmui_performSelector:selector withReturnValue:returnValue arguments:nil];
- (id)qmui_performSelector:(SEL)selector withArguments:(void *)firstArgument, ... {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:selector]];
[invocation setTarget:self];
[invocation setSelector:selector];

if (firstArgument) {
va_list valist;
va_start(valist, firstArgument);
[invocation setArgument:firstArgument atIndex:2];// 0->self, 1->_cmd

void *currentArgument;
NSInteger index = 3;
while ((currentArgument = va_arg(valist, void *))) {
[invocation setArgument:currentArgument atIndex:index];
index++;
}
va_end(valist);
}

[invocation invoke];

const char *typeEncoding = method_getTypeEncoding(class_getInstanceMethod(object_getClass(self), selector));
if (strncmp(typeEncoding, "@", 1) == 0) {
__unsafe_unretained id returnValue;
[invocation getReturnValue:&returnValue];
return returnValue;
}
return nil;
}

- (void)qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue arguments:(void *)firstArgument, ... {
va_list valist;
va_start(valist, firstArgument);
[self _qmui_performSelector:selector withReturnValue:returnValue firstArgument:firstArgument otherArguments:valist];
va_end(valist);
- (void)qmui_performSelector:(SEL)selector withPrimitiveReturnValue:(void *)returnValue {
[self qmui_performSelector:selector withPrimitiveReturnValue:returnValue arguments:nil];
}

- (void)_qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue firstArgument:(void *)firstArgument otherArguments:(va_list)valist {
- (void)qmui_performSelector:(SEL)selector withPrimitiveReturnValue:(void *)returnValue arguments:(void *)firstArgument, ... {
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[self methodSignatureForSelector:selector]];
[invocation setTarget:self];
[invocation setSelector:selector];

if (firstArgument) {
va_list valist;
va_start(valist, firstArgument);
[invocation setArgument:firstArgument atIndex:2];// 0->self, 1->_cmd

void *currentArgument;
@@ -94,6 +108,7 @@ - (void)_qmui_performSelector:(SEL)selector withReturnValue:(void *)returnValue
[invocation setArgument:currentArgument atIndex:index];
index++;
}
va_end(valist);
}

[invocation invoke];
@@ -181,7 +181,7 @@ - (CGFloat)qmui_lineHeight {
}

- (BOOL)_hasSetQmuiLineHeight {
return objc_getAssociatedObject(self, &kAssociatedObjectKey_lineHeight);
return !!objc_getAssociatedObject(self, &kAssociatedObjectKey_lineHeight);
}

- (instancetype)qmui_initWithFont:(UIFont *)font textColor:(UIColor *)textColor {
@@ -201,7 +201,7 @@ - (void)qmui_setTheSameAppearanceAsLabel:(UILabel *)label {
self.textAlignment = label.textAlignment;
if ([self respondsToSelector:@selector(setContentEdgeInsets:)] && [label respondsToSelector:@selector(contentEdgeInsets)]) {
UIEdgeInsets contentEdgeInsets;
[label qmui_performSelector:@selector(contentEdgeInsets) withReturnValue:&contentEdgeInsets];
[label qmui_performSelector:@selector(contentEdgeInsets) withPrimitiveReturnValue:&contentEdgeInsets];
[self qmui_performSelector:@selector(setContentEdgeInsets:) withArguments:&contentEdgeInsets, nil];
}
}

0 comments on commit 49804c2

Please sign in to comment.
You can’t perform that action at this time.