UIImageView extension for procedural generation of beautiful svg shapes
VBRProceduralStrings is available on CocoaPods. Just add the following to your project Podfile:
pod 'VBRProceduralStrings'
Or from GitHub:
pod 'VBRProceduralStrings', :git => 'https://github.com/v-braun/VBRProceduralStrings.git'
VBRProceduralStrings use Macaw to parse the generated SVG content and render it on an CALayer. You should add it also to your Podfile
- Download and drop
VBRProceduralStrings.swift
in your project. - Add Macaw to your project
- Congratulations!
let settings = ProcStringsSettings()
// _svgView is a placeholder that was setup on the main view via interfacebuilder
// see the example project for that
// you should do that in viewDidAppear that guarantee that width and hight has correct values
settings.width = Float(_svgView.bounds.width)
settings.height = Float(_svgView.bounds.height)
settings.lines = 100
settings.points = 8
// horizontal gradients
settings.gradients.append(GradientStep(offset: 0, color: "#03a9f4"))
settings.gradients.append(GradientStep(offset: 70, color: "#e91e63"))
let subView = ProceduralStringGenerator.generateSVGUIView(settings: settings)
self.addSubView(subView)
let settings = ProcStringsSettings()
settings.width = 420
settings.height = 240
settings.lines = 100
settings.points = 8
// horizontal gradients
settings.gradients.append(GradientStep(offset: 0, color: "#03a9f4"))
settings.gradients.append(GradientStep(offset: 70, color: "#e91e63"))
let image = ProceduralStringGenerator.generateSVGImage(settings: settings)
let settings = ProcStringsSettings()
settings.width = 420
settings.height = 240
settings.lines = 100
settings.points = 8
// horizontal gradients
settings.gradients.append(GradientStep(offset: 0, color: "#03a9f4"))
settings.gradients.append(GradientStep(offset: 70, color: "#e91e63"))
let svgString = ProceduralStringGenerator.generateSVGString(settings: settings)
let settings = ProcStringsSettings()
settings.width = 420
settings.height = 240
settings.lines = 100
settings.points = 8
// horizontal gradients
settings.gradients.append(GradientStep(offset: 0, color: "#03a9f4"))
settings.gradients.append(GradientStep(offset: 70, color: "#e91e63"))
myUIImageView.generate(settings: settings)
- Cocoa Rocks: this and other awesome Cocoa Controls
- awesome-cocoa: an awesome list of cocoa controls
- procedural-strings-js: js version of this project
Make sure to read these guides before getting started:
VBRProceduralStrings is available under the MIT License. See LICENSE for details.