我创建了一个自UIButton
定义背景图像、字体和基于设备(iPad 或 iPhone)的不同字体大小的自定义。但是,当我将尺寸类设置为 compact 或将模拟矩阵尺寸设置为 时,interface builder
它会继续使用资源。iPad
iPhone x-inch
界面构建器是否有可能为正确的模拟设备/尺寸使用正确的资源?
@IBDesignable
class BlueButton:UIButton
{
private var isInitialized:Bool = false
override func layoutSubviews()
{
super.layoutSubviews()
if(!isInitialized)
{
isInitialized = true
self.setBackgroundImage(UIImage(name: Style.ButtonImageBlue), forState: .Normal)
self.titleLabel?.font = UIFont(name: Style.FontName, size: UIDevice.currentDevice().userInterfaceIdiom == .Pad ? Style.FontSizePad : Style.FontSizePhone)
}
}
}