-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSideBarMenuTableViewController.swift
More file actions
77 lines (57 loc) · 2.65 KB
/
SideBarMenuTableViewController.swift
File metadata and controls
77 lines (57 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// SideBarMenuTableViewController.swift
// DynamicsDemo
//
// Created by Stefan Buretea on 3/31/15.
// Copyright (c) 2015 Stefan Buretea. All rights reserved.
//
import UIKit
protocol SideBarMenuViewControllerDelegate {
func didSelectItem(indexPath: NSIndexPath)
}
class SideBarMenuTableViewController: UITableViewController, SideBarMenuViewControllerDelegate {
var delegate : SideBarMenuViewControllerDelegate?
var tableData: Array<String> = []
var tableDataImages: Array<String> = []
var lastSelectedCellIndexPath: NSIndexPath?
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return tableData.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier("sideBarMenuCell") as? UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "sideBarMenuCell")
// Configure the cell...
configureCell(cell!)
}
cell!.textLabel?.text = tableData[indexPath.row]
cell!.imageView?.image = UIImage(named: self.tableDataImages[indexPath.row])
cell!.imageView?.tintColor = UIColor.whiteColor()
return cell!
}
private func configureCell(cell: UITableViewCell) {
cell.backgroundColor = UIColor.clearColor()
cell.textLabel?.textColor = UIColor.whiteColor()
cell.textLabel?.font = UIFont(name: "Arial-BoldMT", size: 10.0)
let selectedView = UIView(frame: CGRectMake(0, 0, cell.frame.size.width, cell.frame.size.height))
selectedView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.3)
cell.selectedBackgroundView = selectedView
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 50.0
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.delegate?.didSelectItem(indexPath)
self.lastSelectedCellIndexPath = indexPath
}
func didSelectItem(indexPath: NSIndexPath) {
}
}