在C/Objective-C中,可以使用MIN和MAX宏找到两个数字之间的最小值和最大值.Swift不支持宏,似乎语言/库中没有等价物.每个人都应该有一个定制的解决方案,也许基于这样的仿制药进入一个?
我有一个Objective-C UI组件,我想在Interface Builder中使用Xcode 6进行检查.Swift具有@IBDesignable和@IBInspectable声明属性.它们是否也可用于Objective-C?它们是如何使用的?
我想在IB设计中加载样本图像,UIImageView在编辑界面时在Interface Builder中显示.以下代码不起作用,因为IB中的视图占位符保持为空(视图区域仅包含UIImageView文本):
@IBDesignable
class TestImageView : UIImageView
{
override func prepareForInterfaceBuilder() {
//let bundle = NSBundle.mainBundle()
let bundle = NSBundle(forClass: nil)
let imagePath = bundle.pathForResource("Test", ofType: "jpg")
self.image = UIImage(contentsOfFile: imagePath)
}
}
Run Code Online (Sandbox Code Playgroud)
注意:
UIImageViewIB中图像属性的图像显示).这是用Xcode 6 beta 3测试的.
更新:在这两种情况下,我获得的捆绑路径是"/Applications/Temporary/Xcode6-Beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays".在该路径中,图像显然不存在.
我有一个简单的控制器,显示另一个具有自定义转换的控制器.我用一个坚固的导航栏:
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.barTintColor = [UIColor purpleColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)
这是第二个控制器:

当我MFMailComposeViewController在子控制器中打开一个状态栏时,状态栏是白色的白色(这也附加UIActivityViewController):

事实证明,这与设置modalPresentationStyle为UIModalPresentationCustom:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UIViewController *controller = (UIViewController*)segue.destinationViewController;
// this line cause the bug
//controller.modalPresentationStyle = UIModalPresentationCustom;
controller.transitioningDelegate = self;
}
Run Code Online (Sandbox Code Playgroud)
如果controller.modalPresentationStyle保持不变,状态栏颜色是正确的.而且,这个属性似乎不会干扰自定义转换.
我在这里错过了一些东西?为什么会modalPresentationStyle影响系统控制器中的状态栏类型?这可能是个错误吗?