Menu
gistfile1.txt
// |
// ToggleButton.swift |
// AppSwitcher |
// |
// Created by Suresh on 22/01/19. |
// Copyright © 2019 PmAbi. All rights reserved. |
// |
import Cocoa |
enum ToggleButtonStates { |
case Left |
case Right |
} |
@IBDesignable class ToggleButton: NSControl { |
private var toggle : NSView! |
private var backgroundView : NSView! |
var currentState : ToggleButtonStates = ToggleButtonStates.Left |
var ballInset : CGFloat = 0 |
@IBInspectable var backgroundColor : NSColor = NSColor.green{ |
didSet{ |
backgroundView.layer?.backgroundColor = backgroundColor.cgColor |
} |
} |
@IBInspectable var borderWidth : CGFloat = 0 { |
didSet{ |
backgroundView.layer?.borderWidth = borderWidth |
} |
} |
@IBInspectable var layerCornerColor : NSColor = NSColor.clear { |
didSet{ |
backgroundView.layer?.borderColor = layerCornerColor.cgColor |
} |
} |
override init(frame frameRect: NSRect) { |
super.init(frame: frameRect) |
loadDefaultViews() |
} |
required init?(coder: NSCoder) { |
super.init(coder: coder) |
loadDefaultViews() |
} |
override func draw(_ dirtyRect: NSRect) { |
super.draw(dirtyRect) |
ballInset = bounds.height * 0.2 |
backgroundView.frame = NSRect(x: bounds.origin.x, y: bounds.origin.y, |
width: bounds.size.width, height: bounds.size.height) |
backgroundView.layer?.cornerRadius = bounds.height / 2 |
if currentState .Left{ |
toggle.frame = NSRect(x: bounds.origin.x, y: bounds.origin.y, width: bounds.size.height, height: bounds.size.height) |
}else { |
let x = bounds.width - bounds.height |
toggle.frame = NSRect(x: x, y: bounds.origin.y, width: bounds.size.height, height: bounds.size.height) |
} |
toggle.layer?.cornerRadius = bounds.size.height / 2 |
} |
} |
/* |
Handles View creation Here |
*/ |
extension ToggleButton { |
func loadDefaultViews(){ |
backgroundView = NSView() |
toggle = NSView() |
backgroundView.wantsLayer = true |
backgroundView.layer?.backgroundColor = NSColor.green.cgColor |
addSubview(backgroundView) |
toggle.wantsLayer = true |
toggle.layer?.backgroundColor = NSColor.brown.cgColor |
addSubview(toggle) |
} |
func handleTouch(){ |
moveToggleWithAnimation() |
// print('Current status : (currentState)') |
} |
func moveToggleWithAnimation(){ |
NSAnimationContext.runAnimationGroup({_ in |
//Indicate the duration of the animation |
NSAnimationContext.current.duration = 20.0 |
//What is being animated? In this example I’m making a view transparent |
if currentState ToggleButtonStates.Left{ |
let x = bounds.width - bounds.height |
toggle.frame = NSRect(x: x, y: bounds.origin.y, width: bounds.size.height, height: bounds.size.height) |
}else { |
toggle.frame = NSRect(x: bounds.origin.x, y: bounds.origin.y, width: bounds.size.height, height: bounds.size.height) |
} |
currentState = (currentState .Right) ? ToggleButtonStates.Left : ToggleButtonStates.Right |
}, completionHandler:{ |
//In here we add the code that should be triggered after the animation completes. |
// print('Animation completed') |
self.sendAction(self.action, to: self.target) |
}) |
} |
override func mouseDown(with event: NSEvent) { |
handleTouch() |
} |
} |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Let’s be honest: to the average person, the idea of running two different operating systems at the same time on one computer is pretty weird. This idea naturally leads to questions like these:
Jan 29, 2019 If you’re tired of heading over to System Preferences to make the change, you can use a nifty trick to quickly toggle between Dark mode and Light mode on the Mac right from Spotlight, which effectively allows you to switch the interface themes entirely from the keyboard. How to Create a Dark Mode / Light Mode Toggle for Spotlight in MacOS. From within Mac OS X Lion: To restart your MacBook in Windows, click System Preferences in the Dock and click the Startup Disk icon to display the settings you see here. Click the Windows partition you created in the list to select it (the folder icon will bear the Windows logo, and it will be labeled Windows as well).
- How do I know which one I’m using at any one moment?
- How do I switch between them?
- Which applications do I use?
And of course:
Toggle Macbook Air
- Why would I want to do that?
As a Parallels Desktop® for Mac user, you can probably answer the last two questions like this:
- Because I need to run some Windows applications, and I have (and love) a Mac®.
But you might not know all the ways you can switch between Mac and Windows, so in this blog post I’ll show you. Which one of these ways you might use depends on how you use Parallels Desktop.
Driver Booster. Downloads drivers from within the program. Creates a restore point before updating. Aug 30, 2020. Driver updater with key. Jul 29, 2020. Apr 13, 2020. AVG Driver Updater 2020 Crack + Registration Key Full Free Download LATEST AVG Driver Updater Key makes it easy to fix and update all your device drivers. It automatically checks over 127,000 drivers to help give you less crashing, faster browsing, better graphics, richer audio and fewer device problems.
1. Window Mode
Crack 3dm state of decay pc game. In Window mode, Windows runs in a window on your Mac screen.
You switch between Mac and Windows just be moving your cursor—what could be easier! See Video 1:
2. Full Screen Mode
In Full Screen mode, both Mac and Windows fill the entire screen. You switch between them with a three-finger swipe on your trackpad. See Video 2 (Note: The hand gesture video insets are from lifehacker.com):
Toggle Macro Wow
3. Coherence Mode
Toggle Macro Ahk
Free auto keyboard clicker for mac. In Coherence mode, Mac and Windows applications run side-by-side on the Mac desktop. You switch between them just as you would switch between two Mac applications: just click inside the window of the application you want to use. See Video 3: Your uninstaller taimienphi.
Toggle Macro Excel
I hope these three ways help you to easily and quickly switch between Mac and Windows whenever you want.
Toggl Macstories
Try Parallels Desktop for free for 14 days!