iOS13部分適配

1、UIApplication的keyWindow被標記爲API_DEPRECATED,獲取的爲nil

修改爲[[[UIApplication sharedApplication] windows] objectAtIndex:0]

2、OS13中通過KVC方式來獲取私有屬性,有Carsh風險,訪問私有變量崩潰,比如 UITextField * searchField =[_searchBar valueForKey:@"_searchField"];

在13中把SearchBar中的textField直接暴露給開發者使用,直接使用self.searchTextField;

    if ([self.textfield respondsToSelector:@selector(setAttributedPlaceholder:)]) {

        UIColor *color = kHBColorManager.kColorThreeLevelText;

        self.textfield.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName: color}];

    } else {

        self.textfield.placeholder = placeholder;

    }

禁止使用 [UITextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor”];修改爲attributedPlaceholder

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章