Skip to content
This repository has been archived by the owner on Mar 22, 2020. It is now read-only.

Commit

Permalink
修复一些切换回默认主题时的崩溃问题,优化附加功能页主题应用代码,增加设置页主题应用代码
Browse files Browse the repository at this point in the history
  • Loading branch information
kagurazakayashi committed Jun 20, 2015
1 parent a0d4939 commit 6be4a15
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 82 deletions.
Binary file not shown.
93 changes: 33 additions & 60 deletions CloudEmoticon2iOS/AddonTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,14 @@ class AddonTableViewController: UITableViewController {
self.title = lang.uage("附加工具")

//MARK - 主题
self.navigationController?.navigationBar.barTintColor = UIColor(red: 33/255, green: 150/255, blue:243/255, alpha: 1)
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
let titlecolor = NSDictionary(object: UIColor.whiteColor(),
forKey:NSForegroundColorAttributeName)
self.navigationController?.navigationBar.titleTextAttributes = titlecolor as [NSObject : AnyObject]

颜文字表格背景.frame = self.tableView.frame
// self.view.insertSubview(颜文字表格背景, atIndex: 0)
// self.view.insertSubview(颜文字表格背景, belowSubview: self.tableView)
// self.view.insertSubview(颜文字表格背景, aboveSubview: self.tableView)
self.tableView.backgroundView = 颜文字表格背景
let backgroundView2:UIView = UIView(frame: self.tableView.frame)
backgroundView2.backgroundColor = UIColor.orangeColor()
// backgroundView2.backgroundColor = UIColor.orangeColor()
// self.tableView.insertSubview(backgroundView2, aboveSubview: self.tableView.backgroundView!)
// self.tableView.insertSubview(backgroundView2, atIndex: 1)
self.tableView.backgroundView?.addSubview(backgroundView2)
Expand All @@ -65,12 +61,32 @@ class AddonTableViewController: UITableViewController {
切换主题()
}

override func viewDidAppear(animated: Bool) {
self.tableView.reloadData()
}

func 屏幕旋转() {
刷新背景图()
}

func 切换主题() {
NSLog("[Skin]->AddonTableViewController")
//默认设置
UINavigationBar.appearance().setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.barTintColor = 全局_默认导航栏背景颜色
let navigation_seg_tintcolor_dic:NSDictionary = NSDictionary(object: UIColor.whiteColor(),
forKey:NSForegroundColorAttributeName)
self.navigationController?.navigationBar.titleTextAttributes = navigation_seg_tintcolor_dic as [NSObject : AnyObject]
let backgroundView2:UIView = self.tableView.backgroundView?.subviews[0] as! UIView
backgroundView2.backgroundColor = UIColor.whiteColor()
列表文字颜色 = UIColor.blackColor()
列表当前选中的行背景色 = 全局_默认当前选中行颜色
列表当前选中的行背景图片 = nil
bgpview.image = nil
颜文字表格背景.image = nil
bgpview.alpha = 1
颜文字表格背景.alpha = 1

if (全局_皮肤设置.count > 0 && 全局_皮肤设置.objectForKey("md5") != nil) {
let 主题参数转对象:Skin2Object = Skin2Object()
//图片文件名:顶端导航栏背景图片 yes
Expand All @@ -80,11 +96,7 @@ class AddonTableViewController: UITableViewController {
let navigation_bar_image:UIImage? = 主题参数转对象.image(navigation_bar_image_S) //tool_backgroundimage_S
if (navigation_bar_image != nil) {
UINavigationBar.appearance().setBackgroundImage(navigation_bar_image, forBarMetrics: UIBarMetrics.Default)
} else {
UINavigationBar.appearance().setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
}
} else {
UINavigationBar.appearance().setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
}
//RGBA色值:顶端导航栏背景颜色 yes
let navigation_bar_bgcolor_S:String = 全局_皮肤设置.objectForKey("navigation_bar_bgcolor") as! String
Expand All @@ -93,11 +105,7 @@ class AddonTableViewController: UITableViewController {
let navigation_bar_bgcolor:UIColor? = 主题参数转对象.color(navigation_bar_bgcolor_S) //navigation_bar_bgcolor_S
if (navigation_bar_bgcolor != nil) {
self.navigationController?.navigationBar.barTintColor = navigation_bar_bgcolor
} else {
self.navigationController?.navigationBar.barTintColor = 全局_默认导航栏背景颜色
}
} else {
self.navigationController?.navigationBar.barTintColor = 全局_默认导航栏背景颜色
}
//RGBA色值:顶端导航栏文字颜色 yes
let navigation_seg_tintcolor_S:String = 全局_皮肤设置.objectForKey("navigation_seg_tintcolor") as! String
Expand All @@ -108,29 +116,15 @@ class AddonTableViewController: UITableViewController {
let navigation_seg_tintcolor_dic:NSDictionary = NSDictionary(object: navigation_seg_tintcolor!,
forKey:NSForegroundColorAttributeName)
self.navigationController?.navigationBar.titleTextAttributes = navigation_seg_tintcolor_dic as [NSObject : AnyObject]
} else {
let navigation_seg_tintcolor_dic:NSDictionary = NSDictionary(object: UIColor.whiteColor(),
forKey:NSForegroundColorAttributeName)
self.navigationController?.navigationBar.titleTextAttributes = navigation_seg_tintcolor_dic as [NSObject : AnyObject]
}
} else {
let navigation_seg_tintcolor_dic:NSDictionary = NSDictionary(object: UIColor.whiteColor(),
forKey:NSForegroundColorAttributeName)
self.navigationController?.navigationBar.titleTextAttributes = navigation_seg_tintcolor_dic as [NSObject : AnyObject]
}
//RGBA色值:列表的背景色 yes
let table_bgcolor_S:String = 全局_皮肤设置.objectForKey("table_bgcolor") as! String
NSLog("[Skin]table_bgcolor_S=%@",table_bgcolor_S)
let backgroundView2:UIView = self.tableView.backgroundView?.subviews[0] as! UIView
if (table_bgcolor_S != "null") {
let table_bgcolor:UIColor? = 主题参数转对象.color(table_bgcolor_S) //table_bgcolor_S
if (table_bgcolor != nil) {
backgroundView2.backgroundColor = table_bgcolor
} else {
backgroundView2.backgroundColor = UIColor.whiteColor()
}
} else {
backgroundView2.backgroundColor = UIColor.whiteColor()
}
//RGBA色值:列表文字颜色 yes
let table_textcolor_S:String = 全局_皮肤设置.objectForKey("table_textcolor") as! String
Expand All @@ -139,11 +133,7 @@ class AddonTableViewController: UITableViewController {
let table_textcolor:UIColor? = 主题参数转对象.color(table_textcolor_S) //table_textcolor_S
if (table_textcolor != nil) {
列表文字颜色 = table_textcolor!
} else {
列表文字颜色 = UIColor.blackColor()
}
} else {
列表文字颜色 = UIColor.blackColor()
}
//RGBA色值:列表当前选中的行背景色 yes
let table_selectcolor_S:String = 全局_皮肤设置.objectForKey("table_selectcolor") as! String
Expand All @@ -152,11 +142,7 @@ class AddonTableViewController: UITableViewController {
let table_selectcolor:UIColor? = 主题参数转对象.color(table_selectcolor_S) //table_selectcolor_S
if (table_selectcolor != nil) {
列表当前选中的行背景色 = table_selectcolor!
} else {
列表当前选中的行背景色 = 全局_默认当前选中行颜色
}
} else {
列表当前选中的行背景色 = 全局_默认当前选中行颜色
}
//图片文件名:列表当前选中的行背景图片 yes
let table_selectimage_S:String = 全局_皮肤设置.objectForKey("table_selectimage") as! String
Expand All @@ -165,11 +151,7 @@ class AddonTableViewController: UITableViewController {
let table_selectimage:UIImage? = 主题参数转对象.image(table_selectimage_S) //table_selectimage_S
if (table_selectimage != nil) {
列表当前选中的行背景图片 = table_selectimage!
} else {
列表当前选中的行背景图片 = nil
}
} else {
列表当前选中的行背景图片 = nil
}
刷新背景图()
self.tableView.reloadData()
Expand Down Expand Up @@ -199,31 +181,23 @@ class AddonTableViewController: UITableViewController {
颜文字表格背景.contentMode = UIViewContentMode.ScaleAspectFill
let 主题参数转对象:Skin2Object = Skin2Object()
let 取背景图:String = 主题参数转对象.判断应该显示的背景图()
let background_image_S:String = 全局_皮肤设置.objectForKey(取背景图) as! String
NSLog("[Skin]%@_S=%@",取背景图,background_image_S)
if (background_image_S != "null") {
let background_image_S:String? = 全局_皮肤设置.objectForKey(取背景图) as? String
if (background_image_S != nil && background_image_S != "null") {
NSLog("[Skin]%@_S=%@",取背景图,background_image_S!)
let background_image:UIImage? = 主题参数转对象.image(background_image_S) //background_image_S
if (background_image != nil) {
颜文字表格背景.image = background_image!
} else {
颜文字表格背景.image = nil
}
} else {
颜文字表格背景.image = nil
}

//图片文件名:云颜文字左侧分类列表背景图片
let cloudemo_typetable_bgimage_S:String = 全局_皮肤设置.objectForKey("cloudemo_typetable_bgimage") as! String
NSLog("[Skin]cloudemo_typetable_bgimage_S=%@",cloudemo_typetable_bgimage_S)
if (cloudemo_typetable_bgimage_S != "null") {
//图片文件名:列表背景图片
let cloudemo_typetable_bgimage_S:String? = 全局_皮肤设置.objectForKey("cloudemo_typetable_bgimage") as? String
if (cloudemo_typetable_bgimage_S != nil && cloudemo_typetable_bgimage_S != "null") {
NSLog("[Skin]cloudemo_typetable_bgimage_S=%@",cloudemo_typetable_bgimage_S!)
let cloudemo_typetable_bgimage:UIImage? = 主题参数转对象.image(cloudemo_typetable_bgimage_S) //cloudemo_typetable_bgimage_S
if (cloudemo_typetable_bgimage != nil) {
bgpview.image = cloudemo_typetable_bgimage
} else {
bgpview.image = nil
}
} else {
bgpview.image = nil
}
}
}
Expand Down Expand Up @@ -259,15 +233,14 @@ class AddonTableViewController: UITableViewController {
let 选中行背景视图:UIImageView = UIImageView(frame: cell!.frame)
cell?.selectedBackgroundView = 选中行背景视图
}
let 选中行背景视图:UIImageView = cell?.selectedBackgroundView as! UIImageView
选中行背景视图.backgroundColor = 列表当前选中的行背景色
选中行背景视图.image = 列表当前选中的行背景图片
cell?.textLabel?.textColor = 列表文字颜色
if (list.count > 0) {
let 选中行背景视图:UIImageView = cell?.selectedBackgroundView as! UIImageView
选中行背景视图.backgroundColor = 列表当前选中的行背景色
选中行背景视图.image = 列表当前选中的行背景图片
cell?.textLabel?.textColor = 列表文字颜色
cell?.textLabel?.text = list.objectAtIndex(indexPath.row) as? String
} else {
cell?.textLabel?.text = ""
//cell?.detailTextLabel?.text = ""
}
return cell!
}
Expand Down
12 changes: 6 additions & 6 deletions CloudEmoticon2iOS/CEViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -367,19 +367,19 @@ class CEViewController: UIViewController, UIGestureRecognizerDelegate, UITableVi
} else {
let 主题参数转对象:Skin2Object = Skin2Object()
let 取背景图:String = 主题参数转对象.判断应该显示的背景图()
let background_image_S:String = 全局_皮肤设置.objectForKey(取背景图) as! String
NSLog("[Skin]%@_S=%@",取背景图,background_image_S)
if (background_image_S != "null") {
let background_image_S:String? = 全局_皮肤设置.objectForKey(取背景图) as? String
if (background_image_S != nil && background_image_S != "null") {
NSLog("[Skin]%@_S=%@",取背景图,background_image_S!)
let background_image:UIImage? = 主题参数转对象.image(background_image_S) //background_image_S
if (background_image != nil) {
颜文字表格背景.image = background_image!
}
}

//图片文件名:云颜文字左侧分类列表背景图片
let cloudemo_typetable_bgimage_S:String = 全局_皮肤设置.objectForKey("cloudemo_typetable_bgimage") as! String
NSLog("[Skin]cloudemo_typetable_bgimage_S=%@",cloudemo_typetable_bgimage_S)
if (cloudemo_typetable_bgimage_S != "null") {
let cloudemo_typetable_bgimage_S:String? = 全局_皮肤设置.objectForKey("cloudemo_typetable_bgimage") as? String
if (cloudemo_typetable_bgimage_S != nil && cloudemo_typetable_bgimage_S != "null") {
NSLog("[Skin]cloudemo_typetable_bgimage_S=%@",cloudemo_typetable_bgimage_S!)
let cloudemo_typetable_bgimage:UIImage? = 主题参数转对象.image(cloudemo_typetable_bgimage_S) //cloudemo_typetable_bgimage_S
if (cloudemo_typetable_bgimage != nil) {
bgpview.image = cloudemo_typetable_bgimage
Expand Down
6 changes: 3 additions & 3 deletions CloudEmoticon2iOS/MyEmoticonViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ class MyEmoticonViewController: UIViewController, UITableViewDelegate, UIAlertVi
} else {
let 主题参数转对象:Skin2Object = Skin2Object()
let 取背景图:String = 主题参数转对象.判断应该显示的背景图()
let background_image_S:String = 全局_皮肤设置.objectForKey(取背景图) as! String
NSLog("[Skin]%@_S=%@",取背景图,background_image_S)
if (background_image_S != "null") {
let background_image_S:String? = 全局_皮肤设置.objectForKey(取背景图) as? String
if (background_image_S != nil && background_image_S != "null") {
NSLog("[Skin]%@_S=%@",取背景图,background_image_S!)
let background_image:UIImage? = 主题参数转对象.image(background_image_S) //table_selectimage_S
if (background_image != nil) {
bgpview.image = background_image!
Expand Down
Loading

0 comments on commit 6be4a15

Please sign in to comment.