iOS知识点

2020-08-27  本文已影响0人  MoneyRobber

ui相关

- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    if (self.userInteractionEnabled == NO || self.alpha < 0.01 || self.hidden == YES)
    {
        return nil;
    }
    
    if ([self pointInside:point withEvent:event])
    {
        __block UIView *hitView;
        [self.subviews enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            CGPoint covertPoint = [self convertPoint:point toView:obj];
            hitView = [obj hitTest:covertPoint withEvent:event];
            *stop = YES;
        }];
        if (hitView) {
            return hitView;
        }
        return self;
    }
    return nil;
}

事件响应链
subview -> superview -> ViewController.view -> ViewController -> UIWindow -> UIApplication
事件按照上面的链条传递,如果到UIApplication还没有被处理就被丢弃

oc语言相关

runtime

block

多线程

runloop

网络

UDP&TCP
https://github.com/CyC2018/CS-Notes/blob/master/notes/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%20-%20%E4%BC%A0%E8%BE%93%E5%B1%82.md

设计模式

+ (instancetype)sharedInstance {
    static id _instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[SomeClass alloc] init];
    });
    return _instance;
}
上一篇下一篇

猜你喜欢

热点阅读