【问题标题】:How to use custom background image or color using Promotion如何使用 Promotion 使用自定义背景图像或颜色
【发布时间】:2013-05-22 18:06:19
【问题描述】:

我正在尝试使用 Promotion 构建 iOS 应用。只要它工作正常 因为我使用默认设计中的构建。但我希望能够设置例如样式 我想要的导航栏(不同的颜色和不同的背景图像)。

如何使用促销来做到这一点?

谢谢!

【问题讨论】:

    标签: rubymotion


    【解决方案1】:

    您可以使用 Teacup 轻松自定义视图。 https://github.com/rubymotion/teacup

    将茶杯添加到您的gemfile,在app/styles/appearence.rb 中创建一个文件appearence.rb 并粘贴以下代码:

    Teacup::Appearance.new do
    
      style UINavigationBar, {
        tintColor: UIColor.blackColor
      }
    
      style UIBarButtonItem, {
        tintColor: UIColor.blackColor
      }
    
      style UITableViewCell, {
        layer: {  # style the layer!
          shadowRadius: 3
        },
        backgroundView: {  # style the background!
          backgroundColor: UIColor.blackColor
        },
        imageView: {  # style the imageView!
          contentMode: UIViewContentModeScaleAspectFill
        }
      }
    
      style UISearchBar, {
        tintColor: UIColor.colorWithRed(0.733, green:0.733, blue:0.733, alpha:1)
      }
    end
    

    在加载视图之前将此行添加到您的应用委托

    Teacup::Appearance.apply
    

    希望对你有帮助。

    【讨论】:

    • 这绝对有效。我在我的应用程序中使用它。我不知道 UIAppearance 将如何在一些“尚未发布”的 iOS 版本中工作,但对于 iOS 6,它工作得很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    • 1970-01-01
    相关资源
    最近更新 更多