Browse Source

修复按钮不显示问题

liuzhenxing1118 2 years ago
parent
commit
c63d341a90
1 changed files with 5 additions and 16 deletions
  1. 5 16
      ChineseMedicine/View/SKTagButton.m

+ 5 - 16
ChineseMedicine/View/SKTagButton.m

@@ -32,23 +32,12 @@
 
 - (void)changeStyle:(NSString*)title titleColor:(UIColor*)titleColor backgroundColor:(UIColor*)backgroundColor {
     [self setUserInteractionEnabled:false];
-    //背景
+    [self setAttributedTitle:[[NSAttributedString alloc] initWithString:title attributes:@{
+        NSForegroundColorAttributeName:titleColor,
+        NSFontAttributeName:[UIFont systemFontOfSize:10 weight:500],
+    }] forState:UIControlStateNormal];
+    [self setContentEdgeInsets:UIEdgeInsetsMake(2, 5, 2, 5)];
     [self setBackgroundColor:backgroundColor];
-    
-    if (@available(iOS 15.0, *)) {
-        //文字,大小
-        UIButtonConfiguration* config = [UIButtonConfiguration plainButtonConfiguration];
-        [config setContentInsets:NSDirectionalEdgeInsetsMake(2, 5, 2, 5)];
-        config.attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:@{
-            NSForegroundColorAttributeName:titleColor,
-            NSFontAttributeName:[UIFont systemFontOfSize:10 weight:500],
-        }];
-        [self setConfiguration:config];
-    } else {
-        self.titleLabel.font = [UIFont systemFontOfSize:10.0 weight:500];
-        [self.titleLabel setTextColor:titleColor];
-        self.contentEdgeInsets = UIEdgeInsetsMake(2, 5, 2, 5);
-    }
 }
 
 - (NSString*)getRiskTitle:(NSInteger)type {