在之前版本的Swift中,我能够使用kABPersonCreationDateProperty来自AddressBook框架的电话获取手机中创建联系人的日期.
现在Apple已迁移到Contacts框架,我没有找到一种方法来检索在其文档中创建联系人的日期
如何检索在Swift 2中创建联系人的日期?示例代码将非常感谢:)
我可以UIButton使用以下代码将图像颜色从黑色更改为白色:
extension UIImage {
func maskWith(color: UIColor) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, scale)
let context = UIGraphicsGetCurrentContext()!
context.translateBy(x: 0, y: size.height)
context.scaleBy(x: 1.0, y: -1.0)
context.setBlendMode(.normal)
let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height)
context.clip(to: rect, mask: cgImage!)
color.setFill()
context.fill(rect)
let newImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return newImage
}
}
Run Code Online (Sandbox Code Playgroud)
我正在UIButton使用以下设置图像的颜色:
//creditCardBtn is the the button variable
creditCardBtn.imageView?.image? = (creditCardBtn.imageView?.image?.maskWith(color: .white))!
Run Code Online (Sandbox Code Playgroud)
我的问题
当用户将手指放在按钮上然后慢慢地将手指拖开时,图像颜色会自行重置.我的想法是当有一个时使用@IBAction并重置UIButton图像Touch Up Inside.但是,这并不能阻止图像重置其颜色.
这是我试过的代码:
@IBAction func …Run Code Online (Sandbox Code Playgroud)