Skip to content

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.

Notifications You must be signed in to change notification settings

SwiftCrew/MTLetterImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

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.

    
   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
  

Result

Latter Image

Communication

  • 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:

Created by

Mohd Tahir, @Mohd_Tahir99

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages