Skip to content

Commit

Permalink
License update to 2016 and adapted the colors of the example code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Oster committed Oct 5, 2016
1 parent 50ab805 commit b41ec4a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,4 +1,4 @@
Copyright (c) 2015 Robin Oster <robin.oster@rascor.com>
Copyright (c) 2016 Robin Oster <robin.oster@rascor.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 17 additions & 25 deletions README.md
Expand Up @@ -33,41 +33,33 @@ The usage is really straighforward. Create a UIView in the Storyboard and set th
In the viewDidLoad Method you can add ROStorageBarValues with the following code:
```Swift
override func viewDidLoad() {
super.viewDidLoad()
super.viewDidLoad()

storageBar.add(0.2, title: "Apps", color: UIColor(hex:"#FFABAB"))
storageBar.add(0.15, title: "Documents", color: UIColor(hex:"#FFD29B"))
storageBar.add(0.21, title: "Photos", color: UIColor(hex:"#DDEBF9"))
storageBar.add(0.3, title: "Movies", color: UIColor(hex:"#c3c3c3"))
storageBar.add(0.2, title: "Apps", color: UIColor(hex:"#FFABAB"))
storageBar.add(0.15, title: "Documents", color: UIColor(hex:"#FFD29B"))
storageBar.add(0.21, title: "Photos", color: UIColor(hex:"#DDEBF9"))
storageBar.add(0.3, title: "Movies", color: UIColor(hex:"#c3c3c3"))

// Or if you want to use directly the struct to add an item
storageBar.addStorageBarValue(ROStorageBarValue(value: 0.6, title: "Backups", color: UIColor(hex:"#A8DBA8")))
// Or if you want to use directly the struct to add an item
storageBar.addStorageBarValue(ROStorageBarValue(value: 0.6, title: "Backups", color: UIColor(hex:"#A8DBA8")))

storageBar.unit = "GB"
storageBar.displayTitle = false
storageBar.displayValue = false
storageBar.displayCaption = true
storageBar.titleFontSize = 10.0
storageBar.valueFontSize = 10.0
storageBar.unit = "GB"
storageBar.displayTitle = false
storageBar.displayValue = false
storageBar.displayCaption = true
storageBar.titleFontSize = 10.0
storageBar.valueFontSize = 10.0

var numberFormatter = NSNumberFormatter()
numberFormatter.maximumFractionDigits = 2
numberFormatter.minimumIntegerDigits = 1
var numberFormatter = NSNumberFormatter()
numberFormatter.maximumFractionDigits = 2
numberFormatter.minimumIntegerDigits = 1

storageBar.numberFormatter = numberFormatter
storageBar.numberFormatter = numberFormatter
}
```

The size of the ROStorageBar is defined by the size of the UIView. Therefore also AutoLayout is perfectly working with the ROStorageBar and the adaptation and rerendering is automatically handled by the Library itself. If you have set the displayCaptions to true it does automatically split the view in half. It uses the upper half for the bar and the lower bar for the captions. If there aren't any captions it takes the full height of the UIView.

### UIColor Extension
The extension is only used for easier color creation and can be easily left out. I left it in because maybe someone else can also use the hex to UIColor conversion.

Here a short example:
```Swift
var color = UIColor(hex:"#A8DBA8")
```

## License

```
Expand Down
4 changes: 2 additions & 2 deletions ROStorageBar.podspec
Expand Up @@ -9,12 +9,12 @@

Pod::Spec.new do |spec|
spec.name = 'ROStorageBar'
spec.version = '2.1.1'
spec.version = '2.1.2'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://github.com/prine/ROStorageBar'
spec.authors = { 'Robin Oster' => 'prine.dev@gmail.com' }
spec.summary = 'Dynamic Storage Bar (a là iTunes Usage Bar) written in Swift'
spec.source = { :git => 'https://github.com/prine/ROStorageBar.git', :tag => '2.1.1' }
spec.source = { :git => 'https://github.com/prine/ROStorageBar.git', :tag => '2.1.2' }
spec.source_files = 'Source/**/*'
spec.framework = 'SystemConfiguration'
spec.ios.deployment_target = '8.4'
Expand Down
9 changes: 8 additions & 1 deletion ROStorageBar.xcodeproj/project.pbxproj
Expand Up @@ -169,7 +169,7 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
LastUpgradeCheck = 0800;
ORGANIZATIONNAME = "Robin Oster";
TargetAttributes = {
CB0D1A941A812C3500FC80A8 = {
Expand Down Expand Up @@ -287,8 +287,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -297,6 +299,7 @@
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
Expand Down Expand Up @@ -331,15 +334,18 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
Expand All @@ -349,6 +355,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand Down
10 changes: 5 additions & 5 deletions ROStorageBar/ViewController.swift
Expand Up @@ -15,13 +15,13 @@ class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

storageBar.add(0.2, title: "Apps", color: UIColor.black)
storageBar.add(0.15, title: "Documents", color: UIColor.orange)
storageBar.add(0.21, title: "Photos", color: UIColor.purple)
storageBar.add(0.3, title: "Movies", color: UIColor.red)
storageBar.add(0.2, title: "Apps", color: UIColor(red: 200/255.0, green: 66/255.0, blue: 60/255.0, alpha: 1.0))
storageBar.add(0.15, title: "Documents", color: UIColor(red: 158/255.0, green: 187/255.0, blue: 102/255.0, alpha: 1.0))
storageBar.add(0.21, title: "Photos", color: UIColor(red: 236/255.0, green: 119/255.0, blue: 79/255.0, alpha: 1.0))
storageBar.add(0.3, title: "Movies", color: UIColor(red: 196/255.0, green: 21/255.03, blue: 140/255.0, alpha: 1.0))

// Or if you want to use directly the struct to add an item
storageBar.addStorageBarValue(ROStorageBarValue(value: 0.6, title: "Backups", color: UIColor.green))
storageBar.addStorageBarValue(ROStorageBarValue(value: 0.6, title: "Backups", color: UIColor(red: 247/255.0, green: 168/255.0, blue: 159/255.0, alpha: 1.0)))

storageBar.unit = "GB"
storageBar.displayTitle = false
Expand Down
3 changes: 1 addition & 2 deletions Source/ROStorageBar.swift
Expand Up @@ -3,7 +3,7 @@
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Robin Oster (http://prine.ch)
// Copyright (c) 2016 Robin Oster (http://prine.ch)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -70,7 +70,6 @@ open class ROStorageBar : UIView {
numberFormatter.minimumIntegerDigits = 1
numberFormatter.maximumFractionDigits = 1

// TODO: Check if this is a correct solution
super.init(frame: CGRect.zero)
}

Expand Down

0 comments on commit b41ec4a

Please sign in to comment.