项目详细代码见我的Github,欢迎star。
1.侧栏菜单的实现中,导入了SlideMenuControllerSwift三方库来实现一个滑动菜单。需要注意的适合,需要在AppDelegate.swift进行设置。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.backgroundColor = UIColor.whiteColor()
//一定要在这里添加导航栏才可以实现Back功能
let nav = UINavigationController(rootViewController: ViewController())
let leftViewController = LeftViewController()
let rightViewController = AuthorInfoViewController()
let slideMenuController = SlideMenuController(mainViewController: nav, leftMenuViewController: leftViewController, rightMenuViewController: rightViewController)
self.window?.rootViewController = slideMenuController
self.window?.makeKeyAndVisible()
//设置启动页面停留的时间
NSThread.sleepForTimeInterval(1.0)
return true
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
if indexPath.section == 0{
cell.textLabel?.text = "首页"
cell.accessoryType = UITableViewCellAccessoryType.DetailButton
}
else{
cell.textLabel?.text = themedata[indexPath.row].name
cell.accessoryType = UITableViewCellAccessoryType.DetailButton
// print(cell.textLabel?.text)
}
return cell
}