草庐IT

CF_SWIFT_NAME

全部标签

ios - 如何在 Swift 3.0 中将字符串转换为 UIColor?

我正在尝试将使用预定义颜色列表的现有程序从Objective-C转换为Swift。原始代码使用Selector根据它的名称提取UIColor表示为NSString#defineUIColorFromRGB(rgbValue)[UIColorcolorWithRed:((float)((rgbValue&0xFF0000)>>16))/255.0green:((float)((rgbValue&0xFF00)>>8))/255.0blue:((float)(rgbValue&0xFF))/255.0alpha:1.0]-(UIColor*)getColor:(NSString*)colo

ios - 使用 Swift3 为 iOS 中的 UIButton 设置 'backgroundColor' 动画

我想为我的UIButtons的backgroundColor属性设置动画,但我不确定从哪里开始。我从未使用过CoreAnimation,我什至不确定我是否需要它来做如此基本的事情?我使用一个类和一个看起来像这样的方法来设置按钮的样式:redTheme.swiftfuncmakeRedButton(){self.layer.backgroundColor=myCustomRedcolor} 最佳答案 您可以使用UIViewAnimation来实现,如下所示:注意:在执行动画之前不要忘记将背景设置为清除,否则将无法运行。那是因为动画需要

ios - 使用 ios 图表 swift 3 的折线图

我正在使用ioschart在Swift3中实现折线图。与早期版本的Swift一样,我们有构造函数将x值绑定(bind)到折线图,但在Swift3中似乎没有这样的东西?如果有人有一些意见,请提供帮助。 最佳答案 请试试这个来获取您的X轴值。importUIKitimportChartsclassLineChartViewController:UIViewController{@IBOutletweakvarlineChartView:LineChartView!overridefuncviewDidLoad(){super.viewD

ios - CoreData 对象到 Swift 3 中的 JSON

我正在努力将我的CoreData对象转换为JSON,以便我可以使用它发送到Web服务器。这就是我目前从CoreData获取对象的方式:funcfetchRecord()->[Record]{do{records=trycontext.fetch(Record.fetchRequest())}catch{print("ErrorfetchingdatafromCoreData")}returnrecords}我可以通过这种方式将其显示在我的tableView上:functableView(_tableView:UITableView,cellForRowAtindexPath:Index

ios - 使用 swift3 为 xib 文件中的按钮提供操作

已提供:我的xib中有一个按钮与此相关的swift文件也已附上。问题:此单元格有一个按钮,需要在单击按钮时显示ViewController。此单元格附加到另一个ViewController中的TableView。我想在“BOOK”按钮上执行一个操作,以便在单击时打开新的ViewController。我无法做到这一点,有人可以建议我做些什么吗?代码:importUIKitclassHotelBookingCell:UITableViewCell{@IBOutletweakvarBookbtnOutlet:UIButton!overridefuncawakeFromNib(){super.

ios - 将用户重定向到特定的 ViewController - Swift 4

我试图在删除该地点后将用户重定向到正确的页面。navigationController?.popToRootViewController(animated:true)如果我想重定向到根目录,这将起作用。navigationController?.popViewController(animated:true)如果我想重定向到上一个,这将起作用但在我的例子中,我想重定向到一个特定的页面,而不是根页面或前一个页面。如何在iOS中着手做这样的事情? 最佳答案 如果你现在在你的堆栈中的位置你也可以使用self.navigationContr

iphone - 如何像 [self Method_Name]; 一样使用 self 调用方法;当方法名称很长时 Like -(void)imagePickerController : (UIImagePickerController *)

我是iPhone开发新手。我想知道如何使用self调用方法,例如:[selfMethod_Name];当方法名很长的时候-(void)imagePickerController:(UIImagePickerController*)pickerdidFinishPickingImage:(UIImage*)imageeditingInfo:(NSDictionary*)editingInfo{...}W想使用self调用imagePickerController方法。我尝试用以下方式调用它:[selfimagePickerController];//CrashHere但是代码总是在这一行

objective-c - 如何正确释放一个CF对象对象?

我有这个方法(别人写的!)-(CGPDFDocumentRef)getPdf{NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);NSString*documentsDirectory=[pathsobjectAtIndex:0];NSString*pdfPath=[documentsDirectorystringByAppendingPathComponent:@"myLocalFileName.pdf"];NSURL*pdfURL=[NSURLfile

ios - 如何在 xcode 7 的 Swift 2.0 中使用 NSRegularExpression

//错误在这里letregex=NSRegularExpression(pattern:"()",options:nil,error:nil)//错误是:***cannotfindaninitializerfortypensregularexpressionthatacceptanargumentoftype(pattern:string,ption:nil,error:nil) 最佳答案 Swift2.0中的语法有2处变化:(1)您将调用包装在try...catchblock中,而不是提供error范围;(2)options应该是

ios - swift 3.0 中的 Sha 256 加密语法错误

funcSHA256()->String{letdata=self.data(using:String.Encoding.utf8)letres=NSMutableData(length:Int(CC_SHA256_DIGEST_LENGTH))CC_SHA256((data!asNSData).bytes,CC_LONG(data!.count),UnsafeMutablePointer(res!.mutableBytes))lethashedString="\(res!)".replacingOccurrences(of:"",with:"").replacingOccurrenc