https://github.com/swiftcrew/mtletterimage
This is code if you want to create a UIImage of letters, This code takes the first letter of first and last word, if you want only first latter from string then change the DataProvider setting. This will reduce your project size.
https://github.com/swiftcrew/mtletterimage
latterimage profile profileicon swift5
Last synced: about 1 year ago
JSON representation
This is code if you want to create a UIImage of letters, This code takes the first letter of first and last word, if you want only first latter from string then change the DataProvider setting. This will reduce your project size.
- Host: GitHub
- URL: https://github.com/swiftcrew/mtletterimage
- Owner: SwiftCrew
- Created: 2019-03-22T20:13:00.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-17T12:56:00.000Z (almost 7 years ago)
- Last Synced: 2025-03-31T05:32:45.648Z (over 1 year ago)
- Topics: latterimage, profile, profileicon, swift5
- Language: Swift
- Size: 16.6 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MTLetterImage
This code will generate image from letters(words). Ex. Mohd Tahir image will be generate MT, Choose your `wordsType` First, Last and Both.
## Requirements
- iOS 8.0+
- Xcode 10+
- Swift 4.2
### Code
Get Image from a string.
``` swift
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.
```
``` swift
/// 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
```
## Communication
- If you found a bug, please open an issue. :bow:
- Also, if you have a feature request, please open an issue. :thumbsup:
- If you want to contribute, submit a pull request.:muscle:
## Created by
Mohd Tahir, [@Mohd_Tahir99](https://twitter.com/Mohd_Tahir99)
