小编Net*_*Cod的帖子

使用swift在图像上叠加文本

我试图使用Swift在图像上叠加一些文本,我在这里查看此代码:(src:如何在iOS Swift中向图像添加文本)

这会将文本放在中心位置.我一直在改变价值观

 var rect = CGRectMake(10,150, inImage.size.width,    
   inImage.size.height)
Run Code Online (Sandbox Code Playgroud)

但是我无法在左下角显示文字.有人可以帮助并展示我在这里缺少的东西吗?

我正在使用以下行添加修改后的图像:

modImage = self.textToImage("000", inImage: UIImage(named:"thisImage.png")!, atPoint: CGPointMake(10, 400))
Run Code Online (Sandbox Code Playgroud)

以下是功能......

func textToImage(drawText: NSString, inImage: UIImage, atPoint: CGPoint) -> UIImage{

    // Setup the font specific variables
    var textColor = UIColor.whiteColor()
    var textFont = UIFont(name: "Helvetica Bold", size: 12)!

    // Setup the image context using the passed image
    let scale = UIScreen.mainScreen().scale
    UIGraphicsBeginImageContextWithOptions(inImage.size, false, scale)

    // Setup the font attributes that will be later used to dictate how the text …
Run Code Online (Sandbox Code Playgroud)

image ios swift

4
推荐指数
1
解决办法
7788
查看次数

从Swift中的String中提取某些文本

我希望在Swift 2.x中执行此操作:假设我在文本字段中输入文本.- 'Apple iPhone http://www.apple.com '

我现在正在更新带有标签的UIButton - Apple iPhone.当点击按钮启动' http://www.apple.com时,我想要IBAction .

我可以设置它,但我遇到麻烦的部分是 - 我如何从文本字段解析'Apple iPhone'和' http://www.apple.com '并将它们分开以便我可以更新UIButton标签一些文本并使用URL启动Safari?更具体地说,我希望能够检测"http://"之后的任何"文本",并始终使用文本来更新标签,并使用http来启动带有URL的浏览器.谢谢回答.

regex uitextfield ios swift

0
推荐指数
1
解决办法
1112
查看次数

在algolia中搜索所有出现的字符串

在Algolia,目前我在我的数据库中搜索"亚马逊书籍",其中包含条目

  • 亚马逊包
  • 来自亚马逊的书籍
  • 亚马逊书籍
  • 来自谷歌书籍的书籍

我得到了"亚马逊书"作为结果.我要找的是所有带有"亚马逊"或"书籍"的条目都会显示在结果中.我该如何进行此搜索?

或者我必须从我的iOS应用程序发送多个查询 - 一个用于亚马逊,一个用于swift并解析结果?提前致谢.

search ios algolia

0
推荐指数
1
解决办法
116
查看次数

标签 统计

ios ×3

swift ×2

algolia ×1

image ×1

regex ×1

search ×1

uitextfield ×1