The AvatarGenerator SDK for iOS is a versatile library that allows developers to easily integrate customizable avatar profile pictures into their iOS applications.
-
Customization: Choose from a variety of options, including eye/nose shape, skin color, and more, using the convenient selection form.
-
Easy Integration: Quickly integrate avatar generation into your app with minimal code by utilizing the 'AvatarGeneratorView' in SwiftUI.
-
UIKit and SwiftUI Support: Compatible with both UIKit and SwiftUI, providing flexibility for different app architectures.
-
Delegate Handling: Implement the AvatarGeneratorDelegate protocol for custom handling of the generated avatar image. This allows you to perform specific actions, such as saving the image to the photo library or sharing it.
You can use Swift Package Manager to integrate AvatarGenerator into your Xcode project:
- In your Xcode project, go to File -> Swift Packages -> Add Package Dependency
- Enter the following URL: https://github.com/pshivakumar/iOS-sdk-avatargenerator.git
- Follow the prompts to complete the integration.
- Import the AvatarGenerator module:
import AvatarGenerator- Add the AvatarGeneratorView to your SwiftUI UI:
// Example implementation
@State private var isShowingForm = false
var body: some View {
VStack {
AvatarGeneratorView(
delegate: yourAvatarGeneratorDelegate,
selectedBackgroundColor: $yourBackgroundColor,
selectedEyeShape: $yourEyeShape,
selectedShapeColor: $yourShapeColor,
selectedMouthShape: $yourMouthShape
)
.frame(width: 200, height: 200)
Button("Your Button Name") {
isShowingForm.toggle()
}
.padding()
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.sheet(isPresented: $isShowingForm) {
SelectionFormView(
selectedBackgroundColor: $yourBackgroundColor,
selectedEyeShape: $yourEyeShape,
selectedMouthShape: $yourMouthShape,
selectedShapeColor: $yourShapeColor
)
}
}
}-
(Optional) Implement AvatarGeneratorDelegate for custom handling:
If you want to perform specific actions after generating the avatar image, implement the AvatarGeneratorDelegate protocol in your SwiftUI view or ViewModel.
class YourViewModel: AvatarGeneratorDelegate {
func didGenerateAvatarImage(_ image: UIImage) {
// Handle the generated avatar image
// Example: Save it to the photo library, share it, etc.
}
}-
Check the Sample App:
For detailed implementation check the sample app included in the project
This repository is licensed under the MIT License. You are free to use, modify, and distribute the content, provided you include the appropriate attribution and follow the terms of the license.