在iOS中每个触摸一个按钮,具有不同的操作

时间:2017-11-14 08:50:29

标签: ios swift loops

我想在每次点击时更改文字(或背景或动画或其他内容),最好的方法是什么?

function orderarrayByReferencearrayIds(array $referencearray, array $arrayToSort) {
    // get an array with the id order of the reference array
    $idOrder = array_column($referencearray, 'id');

    usort($arrayToSort, function (array $a, array $b) use ($idOrder) {
        // get the index in reference sort order of each element
        $aIndex = array_search($a['id'], $idOrder);
        $bIndex = array_search($b['id'], $idOrder);

        return $aIndex - $bIndex;
    });

    return $arrayToSort;
}

1 个答案:

答案 0 :(得分:0)

创建大量和一个计数参数

var count = 0
var texts = ["Thanks for grabiN.", "ComeOn you can do iT"]

UIView.animate(withDuration: 1.5) {

   self.button.frame.origin.y = 30
   self.button.frame.size.height = 200
   self.button.frame.size.width = 130

   self.button.backgroundColor = .yellow

   self.text.textColor = .white

   self.text.frame.origin.y += 110
   self.background.backgroundColor = .black

   let index = self.count % self.texts.count
   self.text.text = self.texts[index]
   self.count+=1
}