如何使故事与Instagram相同

时间:2018-07-18 06:17:25

标签: ios iphone image-processing swift3 video-processing

我想要实现一个类似InstagramWhatsApp应用程序的故事(图像和视频)。诸如使用自定义字体和颜色在图像和视频上添加文本等功能。请参见下图作为参考

enter image description here

有什么主意吗?我为Add text on the image推荐了以下内容,但没有太多帮助。

2 个答案:

答案 0 :(得分:0)

尝试一下:

let imagePlaceholder = "[ImagePlaceholder]"
let fullString = String(format: "Hello %@", imagePlaceholder)
let attributes: [NSAttributedStringKey: Any] = [.font: UIFont.systemFont(ofSize: 16), .foregroundColor: UIColor.white]
let attributedString = NSMutableAttributedString(string: fullString, attributes: attributes)

if let imagePlaceholderRange = fullString.range(of: imagePlaceholder) {
    let range = NSRange(imagePlaceholderRange, in: fullString)
    let attachment = NSTextAttachment()
    let myImage = UIImage(named: "MyImage")
    attachment.image = myImage

    let stringAttachment = NSAttributedString(attachment: attachment)
    attributedString.replaceCharacters(in: range, with: stringAttachment)
}
myLabel.attributedText = attributedString

答案 1 :(得分:-2)

您需要添加CSS或任何phostoshop

如果是css,则表示您需要wotk不透明度:0.5 在图片上添加div 添加文字