TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Nov 2017 |
SwiftSwift Version | 4.0 |
SPMSupports SPM | ✗ |
Maintained by Thomas SIVILAY.
An user-friendly UI view to display a price or an amount
We are displaying prices everywhere in our apps and I agree with @frankrausch it’s hard for users to read. Then why not being able to easily have a component that render it for us, doing formatting, styling, layout with just couple properties?
Oh small tip you can use/pair with your designer on the sample playground to adjust the style and have it exactly how you wanted to be.
To integrate PriceView into your Xcode project using CocoaPods, specify it in your Podfile:
target '<Your Target Name>' do
pod 'PriceView'
end
Then, run the following command:
$ pod install
I plan to make PriceView available on Carthage soon as well.
import PriceView
final class ViewController: UIViewController {
private lazy var priceView = UIPriceView()
override func viewDidLoad() {
super.viewDidLoad()
priceView.price = 12.34
}
}
If you don’t like the default behavior of PriceView, it’s fine, and it’s still simple to be used.
This is the list of things available for customization:
Default text style
Style
with variadic parameters init (see TextStyles)TextStyles
Style with variadic text styles
let style = Style(
defaultTextStyle: TextStyle(size: 15, color: .gray, verticalAlignment: .bottom(0)),
textStyles: .integer(TextStyle(size: 32, color: .black, verticalAlignment: .bottom(0)))
)
Style
let style = Style(
integerTextStyle:
TextStyle(size: 32, color: .black, verticalAlignment: .bottom(0)),
decimalTextStyle:
TextStyle(size: 15, color: .gray, verticalAlignment: .bottom(0)),
decimalSeparatorTextStyle:
TextStyle(size: 15, color: .gray, verticalAlignment: .bottom(0)),
currencyTextStyle:
TextStyle(size: 15, color: .gray, verticalAlignment: .bottom(0))
)
UIKonf 2017 – Frank Rausch – Good Typography, Better Apps
PriceView is released under the MIT license. See LICENSE for details.