小编Lea*_*nin的帖子

从文档目录swift获取图像

假设我使用此代码将图像保存到文档directroy

let nsDocumentDirectory = NSSearchPathDirectory.DocumentDirectory
let nsUserDomainMask = NSSearchPathDomainMask.UserDomainMask
if let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true) {
if paths.count > 0 {
    if let dirPath = paths[0] as? String {
        let readPath = dirPath.stringByAppendingPathComponent("Image.png")
        let image = UIImage(named: readPath)
        let writePath = dirPath.stringByAppendingPathComponent("Image2.png") 
        UIImagePNGRepresentation(image).writeToFile(writePath, atomically: true)
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

那我怎么回头呢?牢记在iOS8中,确切的路径经常变化

ios swift nsdocumentdirectory-ios8

35
推荐指数
4
解决办法
6万
查看次数

将UIImage切成圆形

我想把它切成一个UIImage圆圈,然后我可以用它作为注释.我发现这个网站上的每个答案都描述了创建一个UIImageView,然后修改并显示它,但你不能将一个注释的图像设置为一个UIImageView,只有一个UIImage.我该怎么办呢?

uiimage ios swift

32
推荐指数
3
解决办法
3万
查看次数

在Swift中将String转换为CLLocationCoordinate2D

使用Firebase作为我的后端,我有一系列的经纬度坐标字符串,如何将它们转换为CLLocationCoordinate2D以便我可以使用它们进行注释?以下是每次更新时从Firebase获取信息的代码

var UpdateRef = Firebase(url:"https://ici.firebaseio.com/users")

UpdateRef.observeEventType(.ChildChanged, withBlock: { (snapshot) in
    let MomentaryLatitude = snapshot.value["latitude"] as? String
    let MomentaryLongitude = snapshot.value["longitude"] as? String
    let ID = snapshot.value["ID"] as? String

    println("\(MomentaryLatitude)")

    var Coordinates = CLLocationCoordinate2D(latitude: MomentaryLatitude as
        CLLocationDegrees, longitude: MomentaryLongitude as CLLocationDegrees)

}
Run Code Online (Sandbox Code Playgroud)

最后一行不起作用,我应该使用什么呢?

string converter cllocation cllocationcoordinate2d swift

12
推荐指数
1
解决办法
1万
查看次数

以编程方式将图像保存到Swift中的xcassets

假设我的应用程序下载了一个图像,是否可以通过编程方式将其保存到Images.xcassets,以便不必再次下载图像?或者最好的选择是继续从服务器检索它?

image swift

6
推荐指数
3
解决办法
4997
查看次数

将CLLocationCoordinate2D转换为double或int swift

我如何将CLLocationcoordiante转换为double,以便我可以对它进行算术运算并使用它们的大小来比较坐标?在(迅速为ios)

int type-conversion cllocationcoordinate2d swift

2
推荐指数
1
解决办法
5077
查看次数