我目前有一个静态背景颜色:
self.backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
我如何编码在一定的秒数内创建一系列动画颜色(例如每种颜色5秒),然后返回到颜色循环的开头?
我尝试了以下内容......
self.backgroundColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
UIView.animate(withDuration: 5.0, animations: { () -> Void in
self.backgroundColor = UIColor(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0);
self.backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
})
......但这只是留在最后的蓝色。
答案 0 :(得分:2)
您必须制作嵌套动画
self.backgroundColor = UIColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
UIView.animate(withDuration: 5.0, animations: { () -> Void in
self.backgroundColor = UIColor(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0);
},
completion: { finished in
UIView.animate(withDuration: 5.0, animations: { () -> Void in
self.backgroundColor = UIColor(red: 0.0, green: 0.0, blue: 1.0, alpha: 1.0)
}, completion: { finished in
//other color do the same
})
})
答案 1 :(得分:0)
你可以试试这个:
onsubmit: function(e) {
var wholeText = editor.getContent();
var selected_text = editor.selection.getContent();
shortcode = '[checklist-box title="' + e.data.title + '" extraTitle="' + e.data.extraTitle + '" extraUrl="' + e.data.extraUrl + '"]' + selected_text + '[/checklist-box]';
var main = wholeText.replace(selected_text,shortcode);
editor.execCommand('mceSetContent', 0, main);
}