Swift - 点击事件奇偶次判断

 

// 按钮点击事件

    func onTouchUpInside() {

        struct touchUpInside {

            static var count: Int = 0

        }

        touchUpInside.count += 1

        print(touchUpInside.count)

        if touchUpInside.count % 2 == 0 {

            newsView.frame = CGRectMake(10, 22, UIScreen.mainScreen().bounds.size.width - 50, 40)

        } else {

            newsView.frame = CGRectMake(10, 22, UIScreen.mainScreen().bounds.size.width - 50, UIScreen.mainScreen().bounds.size.height - 20)

        }

    }

posted @ 2016-12-22 13:26  公羽寒  阅读(983)  评论(0编辑  收藏  举报