Skip to content

Commit

Permalink
Updated podspec, README, example
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarm committed Oct 1, 2017
1 parent f58fba2 commit 53c4a0e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 50 deletions.
4 changes: 2 additions & 2 deletions BetterSegmentedControl.podspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Pod::Spec.new do |s|
s.name = "BetterSegmentedControl"
s.version = "0.8"
s.version = "0.9"
s.summary = "An easy to use, customizable replacement for UISegmentedControl & UISwitch."
s.description = <<-DESC
BetterSegmentedControl is an easy to use, customizable replacement for UISegmentedControl and UISwitch written in Swift.
DESC
s.homepage = "https://github.com/gmarm/BetterSegmentedControl"
s.license = 'MIT'
s.author = { "George Marmaridis" => "gmarmas@gmail.com" }
s.source = { :git => "https://github.com/gmarm/BetterSegmentedControl.git", :tag => "0.8" }
s.source = { :git => "https://github.com/gmarm/BetterSegmentedControl.git", :tag => "0.9" }
s.social_media_url = 'https://twitter.com/gmarmas'
s.platform = :ios, '8.0'
s.requires_arc = true
Expand Down
14 changes: 13 additions & 1 deletion Example/BetterSegmentedControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACCF1AFB9204008FA782 = {
Expand Down Expand Up @@ -436,14 +436,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -483,14 +489,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
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_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
26 changes: 0 additions & 26 deletions Example/BetterSegmentedControl/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


}

6 changes: 3 additions & 3 deletions Example/BetterSegmentedControl/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="oBL-AA-ynO">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="oBL-AA-ynO">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand Down Expand Up @@ -126,7 +126,7 @@
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="oBL-AA-ynO" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="dU3-Cw-iOr">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
Expand Down
4 changes: 2 additions & 2 deletions Example/BetterSegmentedControl/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ViewController: UIViewController {

// Control 4: Added as a subview
let viewSegmentedControl = BetterSegmentedControl(
frame: CGRect(x: 0.0, y: 302.0, width: view.bounds.width, height: 50.0),
frame: CGRect(x: 0.0, y: 332.0, width: view.bounds.width, height: 50.0),
titles: ["Artists", "Albums"],
index: 1,
options: [.backgroundColor(UIColor(red:0.11, green:0.12, blue:0.13, alpha:1.00)),
Expand All @@ -74,7 +74,7 @@ class ViewController: UIViewController {

// Control 5: Adding custom subview to Indicator
let indicatorControl = BetterSegmentedControl(
frame: CGRect(x: 0.0, y: 375.0, width: view.bounds.width, height: 50.0),
frame: CGRect(x: 0.0, y: 405.0, width: view.bounds.width, height: 50.0),
titles: ["Hello", "Goodbye"],
index: 0, options: [.backgroundColor(.lightGray),
.titleColor(.white),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 22 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BetterSegmentedControl

![](https://img.shields.io/badge/Swift-3.0-blue.svg?style=flat)
![](https://img.shields.io/badge/Swift-4.0-blue.svg?style=flat)
[![Version](https://img.shields.io/cocoapods/v/BetterSegmentedControl.svg?style=flat)](http://cocoapods.org/pods/BetterSegmentedControl)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/BetterSegmentedControl.svg?style=flat)](http://cocoapods.org/pods/BetterSegmentedControl)
Expand Down Expand Up @@ -30,9 +30,14 @@ BetterSegmentedControl is an easy to use, customizable replacement for UISegment
BetterSegmentedControl is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

_Swift 4.0_
```ruby
pod 'BetterSegmentedControl', '~> 0.9'
```

_Swift 3.0_
```ruby
pod 'BetterSegmentedControl', '~> 0.8'
pod 'BetterSegmentedControl', '0.8'
```

_Swift 2.x_
Expand All @@ -44,9 +49,14 @@ pod 'BetterSegmentedControl', '0.4'

If you prefer using [Carthage](https://github.com/Carthage/Carthage), simply add BetterSegmentedControl to your `Cartfile`:

_Swift 4.0_
```ruby
github "gmarm/BetterSegmentedControl" ~> 0.9
```

_Swift 3.0_
```ruby
github "gmarm/BetterSegmentedControl" ~> 0.8
github "gmarm/BetterSegmentedControl" 0.8
```

_Swift 2.x_
Expand All @@ -65,24 +75,24 @@ let control = BetterSegmentedControl(
frame: CGRect(x: 0.0, y: 100.0, width: view.bounds.width, height: 44.0),
titles: ["One", "Two", "Three"],
index: 1,
backgroundColor: UIColor(red:0.11, green:0.12, blue:0.13, alpha:1.00),
titleColor: .white,
indicatorViewBackgroundColor: UIColor(red:0.55, green:0.26, blue:0.86, alpha:1.00),
selectedTitleColor: .black)
control.titleFont = UIFont(name: "HelveticaNeue", size: 14.0)!
control.selectedTitleFont = UIFont(name: "HelveticaNeue-Medium", size: 14.0)!
options: [.backgroundColor(UIColor(red:0.11, green:0.12, blue:0.13, alpha:1.00)),
.titleColor(.white),
.indicatorViewBackgroundColor(UIColor(red:0.55, green:0.26, blue:0.86, alpha:1.00)),
.selectedTitleColor(.black),
.titleFont(UIFont(name: "HelveticaNeue", size: 14.0)!),
.selectedTitleFont(UIFont(name: "HelveticaNeue-Medium", size: 14.0)!)]
)
control.addTarget(self, action: #selector(ViewController.controlValueChanged(_:)), for: .valueChanged)
view.addSubview(control)
```
You can find different ways of using it (such as by designing it in a Storyboard file) in the example project. To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Todos

- [ ] Make initializer throwing if not enough titles are passed.
- [ ] Set titles via method that throws.
- [ ] Get rid of error unnecessary handling.
- [ ] Add snapshot tests.
- [ ] Allow the control to have no selected index.
- [ ] Allow UIViews that implement a protocol to be used as options.
- [ ] Add moar tests!
- [ ] ~~Try to take over the world!~~ Uh, what?

## Contribution
Expand Down

0 comments on commit 53c4a0e

Please sign in to comment.