Giter VIP home page Giter VIP logo

dgrunkeeperswitch's People

Contributors

efremidze avatar gontovnik avatar irfanlone avatar king7532 avatar loganisitt avatar nxtstep avatar parleer avatar sebastianludwig avatar sprint84 avatar takuoka 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

dgrunkeeperswitch's Issues

Empty StoryBoard

Adding storyboard makes it easier to add more UI and design to the projects

Border radius not working when using autolayout in code

In the example app, modify the ViewController.swift's runkeeperSwitch2 to be laid out using autolayout programmatically, like:

        let runkeeperSwitch2 = DGRunkeeperSwitch()
        runkeeperSwitch2.leftTitle = "Weekly"
        runkeeperSwitch2.rightTitle = "Monthly"
        runkeeperSwitch2.backgroundColor = UIColor(red: 239.0/255.0, green: 95.0/255.0, blue: 49.0/255.0, alpha: 1.0)
        runkeeperSwitch2.selectedBackgroundColor = .whiteColor()
        runkeeperSwitch2.titleColor = .whiteColor()
        runkeeperSwitch2.selectedTitleColor = UIColor(red: 239.0/255.0, green: 95.0/255.0, blue: 49.0/255.0, alpha: 1.0)
        runkeeperSwitch2.titleFont = UIFont(name: "HelveticaNeue-Medium", size: 13.0)
        //runkeeperSwitch2.frame = CGRect(x: 50.0, y: 20.0, width: view.bounds.width - 100.0, height: 30.0)
        //runkeeperSwitch2.autoresizingMask = [.FlexibleWidth]
        runkeeperSwitch2.translatesAutoresizingMaskIntoConstraints = false
        view.addSubview(runkeeperSwitch2)

        view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-20-[switch]-20-|", options: .DirectionLeadingToTrailing, metrics: nil, views: ["switch":runkeeperSwitch2]))
        view.addConstraint(NSLayoutConstraint(item: runkeeperSwitch2, attribute: .Top, relatedBy: .Equal, toItem: view, attribute: .Top, multiplier: 1.0, constant: 10))
        runkeeperSwitch2.addConstraint(NSLayoutConstraint(item: runkeeperSwitch2, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute, multiplier: 1.0, constant: 30.0))

And this is what happens in the iOS simulator:

simulator screen shot dec 9 2015 12 27 03 am

Do you have any idea why the border radius is not working using the above code?

Two compiler Errors

I am running this on lates xcode 7 beta 6.

  1. changed this super.init(frame: CGRect.zeroRect) to super.init(frame: CGRect.zero)
    2.The compiler was unable to solve the state at line 239 (rightTitleLabelFrame). i had to break this into two lines
    let tempPoint = CGPoint(x: floor(bounds.size.width / 2.0 + (bounds.width / 2.0 - rightTitleLabelSize.width) / 2.0), y: floor((bounds.height - rightTitleLabelSize.height) / 2.0))
    let rightTitleLabelFrame = CGRect(origin: tempPoint, size: rightTitleLabelSize)

Background color IB setting is overwritten

Any setting of the background color in IB is ignored. This is because and IB-View is instantiated with initWithCoder: which sets the background color. After that finishInit is called which overwrites the setting.

Make it Carthage compatible

Can you make it Carthage compatible?
It's not that hard, just add a Framework build scheme and make it shared.

Code from sample will not work

runkeeperSwitch.addTarget(self, action: #selector(ViewController.switchValueDidChange(sender:)), for: .touchUpInside)

target-action mechanism will not work because of added UITapGestureRecognizer to control

Can't create switch without titles

It fails with error *** Terminating app due to uncaught exception ‘CALayerInvalidGeometry’, reason: ‘CALayer position contains NaN: [nan 15.5]’
As a workaround - create with empty strings ("")

Impossible to use swipes.

Hey! Is it possible to make the value change when I use swipeGestures? I can't do it for some reason.

Regards!

Add Multi-Line Support

A way to handle longer text. Ability to enable multi-line and choose line a lineBreakMode.

error: IB Designables: Failed to update auto layout status

Hello
I have this error with Merge branch 'pr/23' update

error: IB Designables: Failed to update auto layout status: The agent raised a "CALayerInvalidGeometry" exception: CALayer position contains NaN: [nan 15.5]
and
error: IB Designables: Failed to render instance of DGRunkeeperSwitch: The agent threw an exception.

I put the switch into storyboard as navigation title as a view with custom class (DGRunkeeperSwitch)
the position of the view is
x 200
y 7
w 200
h 31
everything else is defaults for the view. without constraints
in code the switch is set with 2 elements

but everything seems to be working as before

ps: the latest version of xcode suggests these changes

        // Gestures
-        tapGesture = UITapGestureRecognizer(target: self, action: "tapped:")
+        tapGesture = UITapGestureRecognizer(target: self, action: #selector(DGRunkeeperSwitch.tapped(_:)))

-        panGesture = UIPanGestureRecognizer(target: self, action: "pan:")
+        panGesture = UIPanGestureRecognizer(target: self, action: #selector(DGRunkeeperSwitch.pan(_:)))

Did you mean to put another version number

I saw that you added swift support but when we try to add this in our pod file it gives an error.

pod 'DGRunkeeperSwitch', '~> 1.1.4'

did you mean to put version 1.1.3?

Pod install using 'use_frameworks!' option

Hi! I'm trying to integrate your project with obj-c code, so i'm using option 'use_frameworks!' for pod install.
When i import this module, none of classes are visible. That is because classes are not public.
Could you please provide public access level for main classes?

P.S. i know that there is already objective-c implementation, but i want to be sure that i'd have your last updates just in time.
Thanks

KVO doesn't work on iOS 11

On iOS 11 there are increased warnings related to KVO and the KVO code in DGRunkeeperSwitch.swift doesn't work. I get this assertion failure
[MyTests.TableViewCellTest testOutlets] : failed: caught "NSUnknownKeyException", "[<DGRunkeeperSwitch.DGRunkeeperSwitch 0x7feec8220100> addObserver:<DGRunkeeperSwitch.DGRunkeeperSwitch 0x7feec8220100> forKeyPath:@"selectedBackgroundView.frame" options:1 context:0x0] was sent to an object that is not KVC-compliant for the "selectedBackgroundView" property."

I fixed this problem as follows:

In finishInit I changed to this

selectedBackgroundView.addObserver(self, forKeyPath: "frame", options: .new, context: nil)

In observeValue forKeyPath I changed to this

override open func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if let view = object as? UIView {
if keyPath == "frame" && view == selectedBackgroundView {
titleMaskView.frame = selectedBackgroundView.frame
}
}
}

and

deinit {
    selectedBackgroundView.removeObserver(self, forKeyPath: "frame")
}

Fix Compilation issues with XCode 6.4 and update settings to make the sample app universal.

Couple of recommendations:

  1. The project should have .gitignore file to ignore files generated during compilation.
  2. With XCode 6.4, the compilation of the app fails.
    a. DGRunkeeperSwitch/UIKit.UIControl:25:18: Non-failable initializer 'init(coder:)' overridden here
    b. DGRunkeeperSwitch/DGRunkeeperSwitch/DGRunkeeperSwitch.swift:207:20: Cannot invoke 'animateWithDuration' with an argument list of type '(NSTimeInterval, delay: Double, usingSpringWithDamping: CGFloat, initialSpringVelocity: CGFloat, options: [UIViewAnimationOptions], animations: () -> Void, completion: (_) -> Void)'
    c. DGRunkeeperSwitch/DGRunkeeperSwitchExample/ViewController.swift:43:47: 'AnyObject.Protocol' does not have a member named 'FlexibleWidth'
  3. Also, it might be more convenient to set the target as Universal for the sample app and let auto layout do its job, rather than having 1X and 2X indicators while running on iPad.

Cheers.

More than two options

Really like what I see, but I would be interested in using DGRunkeeperSwitch with more than two options, more like a Segmented Control. Would be a great enhancement in my opinion!

Best,
Josef

Highlight the need for setting the autoresizingMask in the README

In order for the control to have a flexible width and work with autolayout. You need to add

runkeeperSwitch2.autoresizingMask = [.flexibleWidth]

This is documented in the example project but not in the README. I can't the only one that missed this first time around.

Happy to make a PR updating the README

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.