1.左滑刪除按鈕消失問題,iOS13中層級結(jié)構(gòu)發(fā)生變化。
if (IS_iOSGREATERTHAN13) {
? ? ? ? for(UIView*subviewinself.tableView.subviews) {
? ? ? ? ? ? if([subviewisKindOfClass:NSClassFromString(@"_UITableViewCellSwipeContainerView")] && [subview.subviewscount] >=1) {
? ? ? ? ? ? ? ? for(UIView*subview0insubview.subviews){
? ? ? ? ? ? ? ? ? ? if([subview0isKindOfClass:NSClassFromString(@"UISwipeActionPullView")] && [subview0.subviewscount] >=1){
? ? ? ? ? ? ? ? ? ? ? ? UIButton*deleteButton = subview0.subviews[0];
? ? ? ? ? ? ? ? ? ? ? ? [selfconfigDeleteButton:deleteButton];
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
2.Access to UITextField's _placeholderLabel ivar is prohibited。
UITextFiled? "_placeholderLabel"設(shè)置屬性font等崩潰問題,解決方案:使用swizzle
extension NSObject {
? ? funcgetIvar(name:String) ->Any? {
? ? ? ? guard?let_var =class_getInstanceVariable(type(of:self), name)else{
? ? ? ? ? ? returnnil
? ? ? ? }
? ? ? ? returnobject_getIvar(self, _var)
? ? }
}
extension UITextField {
? ? varplaceholderLabel:UILabel? {
? ? ? ? get{
? ? ? ? ? ? returngetIvar(name:"_placeholderLabel")as?UILabel
? ? ? ? }
? ? }
}
swizzle也操作了私有屬性,對于蘋果來說還是違背了它的意志,雖然現(xiàn)在沒有bug,不保證未來不遇到類似?"_placeholderLabel"崩潰問題。另外一種溫和的方案是設(shè)置attributedPlaceholder。
extension UITextField {
? ? @objc func setPlaceholderColor(_ color: UIColor) {
? ? ? ? letplaceholderString =? NSAttributedString(string:self.placeholder??"", attributes: [NSAttributedString.Key.foregroundColor: color])
? ? ? ? self.attributedPlaceholder= placeholderString
? ? }
? ? @objcfuncsetPlaceholderAttribute(color:UIColor, font:UIFont) {
? ? ? ? letplaceholderString =? NSAttributedString(string:self.placeholder??"", attributes: [NSAttributedString.Key.foregroundColor: color,NSAttributedString.Key.font: font])
? ? ? ? self.attributedPlaceholder= placeholderString
? ? }
}
3.未開發(fā)暗黑模式之前,先不適配暗黑模式。
全局關(guān)閉暗黑模式:
在 Info.plist 文件中,添加 key 為?User Interface Style,類型為 String,value 設(shè)置為?Light?即可。