InitialsImageView
A simple UIImageView extension for using initials as a profile image, written in swift
Install / Use
/learn @bachonk/InitialsImageViewREADME
InitialsImageView
An easy, helpful UIImageView extension that generates letter initials as a placeholder for user profile images, with a randomized background color

Installation
CocoaPods
Add this spec to your podfile:
pod "InitialsImageView"
Check out the official guide for getting started with CocoaPods.
Swift Package Manager
You can use the Swift Package Manager to install InitialsImageView by adding it to the dependencies value of your Package.swift:
dependencies: [
.package(url: "https://github.com/bachonk/InitialsImageView.git", .upToNextMajor(from: "0.0.0"))
]
Manual
- Drag the
InitialsImageView.swiftfile into your project - Enjoy!
Usage
Methods
Call the following methods on any UIImageView instance to set the image:
setImageForName(string: String, backgroundColor: UIColor?, circular: Bool, textAttributes: [String: AnyObject]?)
string is the string used to generate the initials. This should be a user's full name if available.
backgroundColor is an optional parameter that sets the background color of the image. Pass in nil to have a color automatically generated for you.
circular is a boolean parameter that will automatically clip the image to a circle if enabled.
textAttributes is an optional dictionary of predefined character attributes for text. You can find the list of available keys in NSAttributedString
Example
let randomImage: UIImageView = UIImageView.init(frame: CGRect(x: self.view.bounds.midX - 40, y: self.view.bounds.midY - 80 - 40, width: 80, height: 80))
randomImage.setImageForName(string: "Michael Bluth", backgroundColor: nil, circular: true, textAttributes: nil)
Saying Thanks
If you like this tool, show your support by downloading the free Turnout app that inspired it!
License
Using the MIT license. See license file for details.
Related Skills
node-connect
344.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
96.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
