zoukankan      html  css  js  c++  java
  • 6.17 TABLE实现色块的移动

     1 import UIKit
     2 
     3 class ViewController: UIViewController,UITableViewDataSource, UITableViewDelegate
     4 {
     5     
     6     @IBOutlet var redView : UIView
     7     var act = ["","","",""]
     8     
     9     override func viewDidLoad()
    10     {
    11         super.viewDidLoad()
    12         // Do any additional setup after loading the view, typically from a nib.
    13     }
    14     
    15     override func didReceiveMemoryWarning()
    16     {
    17         super.didReceiveMemoryWarning()
    18         // Dispose of any resources that can be recreated.
    19     }
    20     
    21     func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int
    22     {
    23         return act.count
    24     }
    25     
    26     func tableView(tableView:UITableView!,cellForRowAtIndexPath indexPath: NSIndexPath!) ->UITableViewCell!
    27     {
    28         var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("cell1",forIndexPath:indexPath)as UITableViewCell
    29         
    30         cell.textLabel.text = act [indexPath.row]
    31         
    32         println("(indexPath)")
    33         return cell
    34     }
    35     
    36     func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
    37         switch indexPath.row {
    38         case 0:
    39             var frame = redView.frame
    40             var destFrame = CGRect(x: frame.origin.x, y: frame.origin.y - 50,  frame.size.width, height: frame.size.height)
    41             //        redView.frame = destFrame
    42             
    43             UIView.animateWithDuration(3, animations: {
    44                 self.redView.frame = destFrame
    45                 self.redView.backgroundColor = UIColor.purpleColor()
    46                 })
    47         case 1:
    48             var frame = redView.frame
    49             var destFrame = CGRect(x: frame.origin.x, y: frame.origin.y + 50,  frame.size.width, height: frame.size.height)
    50             //        redView.frame = destFrame
    51             
    52             UIView.animateWithDuration(3, animations: {
    53                 self.redView.frame = destFrame
    54                 self.redView.backgroundColor = UIColor.grayColor()
    55                 })
    56         case 2:
    57             var frame = redView.frame
    58             var destFrame = CGRect(x: frame.origin.x - 50, y: frame.origin.y,  frame.size.width, height: frame.size.height)
    59             //        redView.frame = destFrame
    60             
    61             UIView.animateWithDuration(3, animations: {
    62                 self.redView.frame = destFrame
    63                 self.redView.backgroundColor = UIColor.greenColor()
    64                 })
    65         case 3:
    66             var frame = redView.frame
    67             var destFrame = CGRect(x: frame.origin.x + 50, y: frame.origin.y,  frame.size.width, height: frame.size.height)
    68             //        redView.frame = destFrame
    69             
    70             UIView.animateWithDuration(3, animations: {
    71                 self.redView.frame = destFrame
    72                 self.redView.backgroundColor = UIColor.orangeColor()
    73                 })
    74         default:
    75             println("OK")}
    76     }
    77 }
  • 相关阅读:
    hdu 4710 Balls Rearrangement()
    hdu 4707 Pet(DFS水过)
    hdu 4706 Children's Day(模拟)
    hdu 4712 Hamming Distance(随机函数暴力)
    csu 1305 Substring (后缀数组)
    csu 1306 Manor(优先队列)
    csu 1312 榜单(模拟题)
    csu 1303 Decimal (数论题)
    网络爬虫
    Python处理微信利器——itchat
  • 原文地址:https://www.cnblogs.com/changningios/p/3793464.html
Copyright © 2011-2022 走看看