Giter Club home page Giter Club logo

sevenswitch's People

Contributors

andreamazz avatar bvogelzang avatar chingjun avatar cmds4410 avatar dark2torch avatar gavinbunney avatar lidbetter avatar mjarvis avatar mxcl avatar ric2z avatar youknowone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sevenswitch's Issues

Default state shows ON, but switch is off, even in demo

Run the demo app. (Or simply look at the screenshot in the read me, and compare to the animation above them).

Note the blue and green switches have the knob on the left, yet both are colored in.

Tap the knob (don't slide it).

The background color changes to white, indicating the switch is off. Before the tap, the switch was colored on, and the knob hasn't moved!

Incorrect border color when onColor changed and on = YES

The below code is used in UITableView. When onColor is not the default green, and gameCenterSwitch.on is YES, the border is default green. When switched back to NO and YES, the border changes to proper not default green colour.

Workaround: set the colour first, then on = YES.

        SevenSwitch* gameCenterSwitch = [[SevenSwitch alloc] initWithFrame: CGRectMake( 0, 0, 44, 27 )];
        gameCenterSwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey: @"gameCenterAutologin"];
        gameCenterSwitch.onColor = [UIColor colorWithHexString: [[NSUserDefaults standardUserDefaults] objectForKey: @"theme.tintColor"]];

        [gameCenterSwitch addTarget: self action: @selector( gameCenterChanged: ) forControlEvents: UIControlEventValueChanged];

        cell.accessoryView = gameCenterSwitch;

swift 3

can you please update this to swift 3?

Dows not work with iOS 8 / Xcode 6

Getting error when compiling sample app.

SevenSwitch.swift:358:19: Overriding method with selector 'cancelTrackingWithEvent:' has incompatible type '(UIEvent) -> ()'

Weird behavior in scroll view

Hello,

I have noticed a bug: when adding switch in storyboard to scroll view, the switch initially moves in wrong direction for half a second. Below is a screenshot presenting the situation:

simulator screen shot 25 01 2016 09 30 32

Greetings,
Jonasz

Cocoapods, use_frameworks! option, and non-public class

When used as a Cocoapods dependency with use_frameworks! option, I encounter a compilation issue with SevenSwitch class not being found. It looks like SevenSwitch must be made a public class to be exposed... do you confirm?

Broken SetOn Animated

Don't know if this is specific to my case, but upon setting the switch's state to on programmatically works fine when animated is YES, but the knob doesn't move to the correct position when animated is NO. It's only the knob position, the colors and images are updated correctly. I believe its the piece of code in the setOn:animated method. I solved this (in a hackish way) by animating it with a duration of 0, settings isAnimated to YES before and then to NO upon completion and only using the UIAnimationOptionBeginFromCurrentState option. Everything else is the same.

updating the onLabel text repeatedly?

I'm having some trouble updating the onLabel, accessing it via [sevenSwitch.onLabel setText:]. The problem is, the text is updated seemingly at random points ~every 60+ seconds, when I want it to be much faster than that (~10 seconds or faster). I'm using the main queue and setting [sevenSwitch.onLabel setNeedsDisplay] after I update the label. How could I go about fixing this?

Release version with Swift 1.2 support

Hi - could you please push a new version to cocopoads with the fix for Swift 1.2? I tried using the git master branch as the pod target but there's no podspec in the repo.

Thanks!

Thumbview shadow is not correctly set when using autolayout and a different sizes from the default

Hi, it seems that if you use autolayout and a different frame size then the shadow is incorrectly drawn. This is probably because the shadow path is set on initialization and not in layoutSubviews().
The workaround I'm currently using is to set the initial frame's width and height to the ones used in the constraints since you really can't extend the class as most of the properties are internal.
Other than that it works great, thanks in advance.

Support for showing the border in on-state

I'd like to the SevenSwitch as simple left-right switch that looks the same in both states. For this, the border needs to be shown in the on-state. The attached patch accomplishes that, so I can do:

switch.showBorderWhenOn = YES;
switch.activeColor = [UIColor clearColor];
switch.onTintColor = [UIColor clearColor];
diff -r 51c4ea1a814d Frameworks/SevenSwitch-1.3.0/SevenSwitch.h
--- a/SevenSwitch-1.3.0/SevenSwitch.h   Thu Mar 13 09:13:27 2014 +0100
+++ b/SevenSwitch-1.3.0/SevenSwitch.h   Thu Mar 13 09:27:00 2014 +0100
@@ -56,6 +56,12 @@
  */
 @property (nonatomic, strong) UIColor *borderColor;

+
+/*
+ *  Sets whether the border should be shown when the switch is on.
+ */
+@property (nonatomic, assign) BOOL showBorderWhenOn;
+
 /*
  * Sets the knob color. Defaults to white.
  */
diff -r 51c4ea1a814d Frameworks/SevenSwitch-1.3.0/SevenSwitch.m
--- a/SevenSwitch-1.3.0/SevenSwitch.m   Thu Mar 13 09:13:27 2014 +0100
+++ b/SevenSwitch-1.3.0/SevenSwitch.m   Thu Mar 13 09:27:00 2014 +0100
@@ -386,7 +386,11 @@
             else
                 knob.frame = CGRectMake(self.bounds.size.width - (normalKnobWidth + 1), knob.frame.origin.y, normalKnobWidth, knob.frame.size.height);
             background.backgroundColor = self.onTintColor;
-            background.layer.borderColor = self.onTintColor.CGColor;
+           if (self.showBorderWhenOn) {
+               background.layer.borderColor = self.borderColor.CGColor;
+           } else {
+               background.layer.borderColor = self.onTintColor.CGColor;
+           }
             onImageView.alpha = 1.0;
             offImageView.alpha = 0;
         } completion:^(BOOL finished) {
@@ -399,7 +403,11 @@
         else
             knob.frame = CGRectMake(self.bounds.size.width - (normalKnobWidth + 1), knob.frame.origin.y, normalKnobWidth, knob.frame.size.height);
         background.backgroundColor = self.onTintColor;
-        background.layer.borderColor = self.onTintColor.CGColor;
+       if (self.showBorderWhenOn) {
+           background.layer.borderColor = self.borderColor.CGColor;
+       } else {
+           background.layer.borderColor = self.onTintColor.CGColor;
+       }
         onImageView.alpha = 1.0;
         offImageView.alpha = 0;
     }

switches don't toggle properly on objc version

Hi was wondering if I'm doing anything wrong, but I want to use your controller in my app that supports 7.1. So I chose the 1.4 pod install. This code creates buttons that don't toggle easily at all. Your swift example works beautifully though.

    SevenSwitch *mySwitch = [[SevenSwitch alloc] initWithFrame:CGRectZero];
    mySwitch.center = contentView.center;
    mySwitch.on = NO;
    mySwitch.offImage = [UIImage imageNamed:@"cross.png"];
    mySwitch.onImage = [UIImage imageNamed:@"check.png"];
    mySwitch.onTintColor = [UIColor colorWithHue:0.08f saturation:0.74f brightness:1.00f alpha:1.00f];
    mySwitch.isRounded = YES;
    [contentView addSubview:mySwitch];

onThumbTintColor not updated when thumbTintColor is set to a new value

When the thumbTintColor option is changed during runtime, only the off state thumb tint color actually changes because the userDidSpecifyOnThumbTintColor is updated to true during initialization because it is set by the willSet closure of thumbTintColor. I think this is a bug because the onThumbTintColor is not listed in the properties in the README, and likewise nowhere does it document that both properties must be updated in order to make a color change to the thumbView's color.

Getting "Initializer does not override a designated initializer from its superclass" error

In a fresh install of SevenSwift 2.0 I'm getting an error here in SevenSwitch.swift:

override public init() {
super.init(frame: CGRectMake(0, 0, 50, 30))

    self.setup()
}

I saw some people saying change "override public" to "convenience" then "super" to "self" and doing that removes the errors but when I write the test documentation:

let mySwitch = SevenSwitch()

I still get "Use of unresolved identifier 'SevenSwitch'"

Any ideas on why this isn't working?

iOS 10 display issue

I've found a view fragment issue when using SevenSwitch in iOS 10 with the following configuration:

Config:
screen shot 2016-10-11 at 2 19 24 pm

helpQuestionMarkSmall:
whitecirclequestionmark

Default (off) state:
screen shot 2016-10-11 at 2 12 36 pm

On state:
screen shot 2016-10-11 at 2 12 43 pm

As you can see from the screenshots, it's drawing the default background in the bottom-right corner of the screen, and is the wrong size.

images are not resizing

Hi,

are there any image size restriction (width and hight) to adhere to?
I tried to implement onImage, offImage and thumbImage, but they don't adjust to the switch size. Is that correct?

Thanks a lot

[Swift newbee] Error when trying to compile with the Objective-C file

I want to compile the project with the objective-C ViewController.m. What I did:

  • I removed the ViewController.swift from the list of the files to compile
  • I add the ViewController.m from the list of the files to compile

capture d ecran 2015-03-31 a 14 44 02

I get this error:

clang: error: no such file or directory: '/Users/colas/Downloads/SevenSwitch-master 2/SevenSwitchExample/SevenSwitchExample/SevenSwitchExample-Prefix.pch'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1

Furthermore, I don't know how to import the swift file to the .m View Controller.

capture d ecran 2015-03-31 a 14 44 54

CocoaPods Issue

When I add " pod 'SevenSwitch', '~> 2.0' " to my Podfile and try to install, I got this error :

[!] Unable to satisfy the following requirements:

  • SevenSwitch (~> 2.0) required by Podfile

CocoaPods website only find SevenSwitch1.4.0.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.