为什么自定义UIRefreshControl类的背景颜色在Swift中没有变化?

时间:2017-10-27 14:51:42

标签: ios swift uirefreshcontrol

我创建了自定义UIRefreshControl,如下所示:

class CustRefreshCont: UIRefreshControl {

    override func draw(_ rect: CGRect) {
        // Drawing code
        let blueColor: UIColor = UIColor.blue
        let lightGrayColor: UIColor = UIColor.lightGray

        self.tintColor = blueColor
        self.backgroundColor = lightGrayColor

        self.attributedTitle = NSAttributedString(string: "Updating data", attributes: [NSAttributedStringKey.foregroundColor : self.tintColor, NSAttributedStringKey.backgroundColor : self.backgroundColor!])
    }
}

我从UIViewController分配UIRefreshControl的方式复制如下:

    let refreshControl = CustRefreshCont()

正在显示文本和ActivityIndi​​cator自定义,但背景颜色显示为黑色。

我的代码有什么问题?

1 个答案:

答案 0 :(得分:1)

将配置代码移至初始化程序。我不认为public class sample extends Thread{ Context mcontext; public sample(Context context){ this.mcontext = context; } @override public void run(){ scan(mcontext); } public void scan(){ try{ //Code to execute }catch(Exception e){e.printStackTrace} //What to do to exit code here reaching first time } } 方法是正确的做法。

SELECT COUNT(*),
       a.DisplayName0
FROM   v_GS_ADD_REMOVE_PROGRAMS a
WHERE  A.DisplayName0 NOT LIKE 'hotfix for%'
       AND A.DisplayName0 NOT LIKE 'Security Update for%'
GROUP  BY a.DisplayName0
ORDER  BY COUNT(*);