This code will generate image from letters(words). Ex. Mohd Tahir image will be generate MT, Choose your wordsType
First, Last and Both.
- iOS 8.0+
- Xcode 10+
- Swift 4.2
Get Image from a string.
let size = imageViewBothWords.frame.size // current imageViewSize.
// for Both First & Last
let dataProviderBoth = DataProvider(
name: "Mohammad Tahir",
imageSize: size
) // Create DataProvider.
self.imageViewBothWords.image = MTLetterImage.imageWith(dataProvider: dataProviderBoth) // image.
// First Word
let dataProviderFirst = DataProvider(
name: "Mohammad Tahir",
backgroundColor: .red,
imageSize: size,
wordsType: .first
) // Create DataProvider.
self.imageViewFirstWord.image = MTLetterImage.imageWith(dataProvider: dataProviderFirst) // image.
// Last word
let dataProviderLast = DataProvider(
name: "Mohammad Tahir",
backgroundColor: .orange,
textColor: .white,
imageSize: size,
font: UIFont.systemFont(ofSize: 22, weight: .bold),
wordsType: .last
) // Create DataProvider.
self.imageViewLastWord.image = MTLetterImage.imageWith(dataProvider: dataProviderLast) // image.
/// String text for image
public var name: String
/// Image Background Color
public var backgroundColor: UIColor
/// Image Text Color
public var textColor: UIColor
/// Image Size
public var imageSize: CGSize
/// Text Font
public var font: UIFont
/// String Separater
public var componentSeparatedBy: String
- If you found a bug, please open an issue. 🙇
- Also, if you have a feature request, please open an issue. 👍
- If you want to contribute, submit a pull request.:muscle:
Mohd Tahir, @Mohd_Tahir99