哪个是声明Array和Dictionary的更好方法,我使用了两个:
Array<String>
[String]
对我[String]
而言,在编码方面非常快,但实际上两者在编译器和性能方面有何不同,我们应该遵循哪一个?
我正在尝试setTextAttribute
使用此代码在所有视图中使用UnderLine
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor redColor],
// NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
(NSString *) kCTUnderlineStyleAttributeName:@(kCTUnderlineStyleDouble),
NSFontAttributeName: [UIFont fontWithName:@"HelveticaNeue-Bold" size:17]}];
Run Code Online (Sandbox Code Playgroud)
但它不工作,我知道通过创建自定义的另一种方法UILabel
与NSAttributedString
和设置它在titleview的,但没有任何其他的方式来实现这一目标使用外观协议?
我在这里编写简单的代码
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Cancel, target: self, action: Selector("cancelClick"))
Run Code Online (Sandbox Code Playgroud)
实际功能
func cancelClick(isAlert:String = "yes"){
self.dismissViewControllerAnimated(true, completion: { () -> Void in
if isAlert == "yes" {
Functions.displayAlert("called")
}
})
}
Run Code Online (Sandbox Code Playgroud)
self.cancelClick()
- 工作,但如果我没有通过参数 self.cancelClick(isAlert:"no")
- 坠毁那么如果我必须在默认参数中传递参数,我的选择器应该是什么Selector("cancelClick")
,Selector("cancelClick:")
但都尝试过但没有运气。