我正在尝试将模板图像添加到幻灯片菜单 Controller (基于此 SideMenuController component )。但我对色调有疑问。原始图像是深灰色的,我希望它们是白色的。我已经设置了 .alwaysTemplate 模式并以编程方式着色颜色,但我得到的不是必需的行为:
即,仅当我点击该菜单项时,色调颜色才会从灰色变为白色。你知道如何解决这个问题吗?
这是我的导航菜单 Controller 代码:
class NavigationMenuController: UITableViewController {
@IBOutlet weak var groupsIcon: UIImageView!
@IBOutlet weak var calendarIcon: UIImageView!
@IBOutlet weak var documentsIcon: UIImageView!
@IBOutlet weak var settingsIcon: UIImageView!
private let gradientTop = UIColor.fromHexadecimal(0xF3736F)
private let gradientBottom = UIColor.fromHexadecimal(0xEC92AE)
private let cellSelection = UIColor.fromHexadecimal(0xEC92AE)
private let menuIconTint = UIColor.fromHexadecimal(0xFFFFFF)
private let segues = [
"embedGroupsController",
"embedCalendarController",
"embedRulesController",
"embedSettingsController"
]
override func viewDidLoad() {
super.viewDidLoad()
let gradient = CAGradientLayer()
gradient.colors = [gradientTop.cgColor, gradientBottom.cgColor]
gradient.locations = [0.0, 1.0]
gradient.frame = tableView.bounds
let backgroundView = UIView(frame: tableView.bounds)
backgroundView.layer.insertSublayer(gradient, at: 0)
tableView.backgroundView = backgroundView
let imageViews: [UIImageView] = [groupsIcon, calendarIcon, documentsIcon, settingsIcon]
for imageView in imageViews {
guard let image = imageView.image else { fatalError("Image not found") }
let templateImage = image.withRenderingMode(.alwaysTemplate)
imageView.image = templateImage
imageView.tintColor = menuIconTint
}
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
let bgColorView = UIView()
bgColorView.backgroundColor = cellSelection
cell.selectionStyle = .default
cell.backgroundColor = .clear
cell.selectedBackgroundView = bgColorView
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let sideMenu = sideMenuController else {
fatalError("Side menu controller is not configured")
}
if indexPath.row >= segues.count {
fatalError("Unexpected row index: \(indexPath.row)")
}
sideMenu.performSegue(withIdentifier: segues[indexPath.row], sender: nil)
}
}
我也尝试通过 Storyboard 和 Assets 设置来做到这一点,但效果相同。我在 iOS 10 和 Swift 3 上运行这个应用程序。
最佳答案
我对单元格内的 UIImageView 色调也有同样的问题。
我通过将 ImageView 色调设置为默认值并改为设置单元格的内容 View 色调来修复它。
关于ios - 单击 UITableViewCell 上的 UIImageView 模板图像色调颜色更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44541673/
如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设
我正在使用puppet为ruby程序提供一组常量。我需要提供一组主机名,我的程序将对其进行迭代。在我之前使用的bash脚本中,我只是将它作为一个puppet变量hosts=>"host1,host2"我将其提供给bash脚本作为HOSTS=显然这对ruby不太适用——我需要它的格式hosts=["host1","host2"]自从phosts和putsmy_array.inspect提供输出["host1","host2"]我希望使用其中之一。不幸的是,我终其一生都无法弄清楚如何让它发挥作用。我尝试了以下各项:我发现某处他们指出我需要在函数调用前放置“function_”……这
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我尝试使用不同的ssh_options在同一阶段运行capistranov.3任务。我的production.rb说:set:stage,:productionset:user,'deploy'set:ssh_options,{user:'deploy'}通过此配置,capistrano与用户deploy连接,这对于其余的任务是正确的。但是我需要将它连接到服务器中配置良好的an_other_user以完成一项特定任务。然后我的食谱说:...taskswithoriginaluser...task:my_task_with_an_other_userdoset:user,'an_othe
我想设置一个默认日期,例如实际日期,我该如何设置?还有如何在组合框中设置默认值顺便问一下,date_field_tag和date_field之间有什么区别? 最佳答案 试试这个:将默认日期作为第二个参数传递。youcorrectlysetthedefaultvalueofcomboboxasshowninyourquestion. 关于ruby-on-rails-date_field_tag,如何设置默认日期?[rails上的ruby],我们在StackOverflow上找到一个类似的问
我将我的Rails应用程序部署到OpenShift,它运行良好,但我无法在生产服务器上运行“Rails控制台”。它给了我这个错误。我该如何解决这个问题?我尝试更新rubygems,但它也给出了权限被拒绝的错误,我也无法做到。railsc错误:Warning:You'reusingRubygems1.8.24withSpring.UpgradetoatleastRubygems2.1.0andrun`gempristine--all`forbetterstartupperformance./opt/rh/ruby193/root/usr/share/rubygems/rubygems
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的