How do I create a NSToggleButton in Interface Builder? - iphone

I want to make an NSToggleButton because it suits my needs perfectly: show one image when toggled on, another when it's toggled off.
From Apple's Developer website:
"After the first click, the button displays its alternate image or title; a second click returns the button to its normal state.
This option is called “Toggle” in Interface Builder’s Button Inspector.
Available in OS X v10.0 and later."
- Source
When looking at the Round Rect Button I created in Interface Builder, however, I can't find a "Toggle" attribute. My google and StackOverflow searches yield only questions around attributes for the control, but I haven't found a tutorial for creating this button in particular.
How do I create a NSToggleButton in Interface Builder? Where is it in the Object library?

The source you provdided is for OSX programming. Not iOS however this can be implemented yourself. A UIButton is just a UIView so add a UIImageView as a subview then when the button is clicked set hidden to either YES or NO

NSToggleButton is an AppKit class -- MacOS X only. You won't find it if you're building an iOS app. Classes from the Foundation framework have an NS prefix and are available in iOS (NSArray, NSDictionary, etc.), but the user interface classes in iOS are in UIKit and have a UI prefix. Take a look at UISwitch for similar functionality.

Related

Can I use the system Touch Bar icons in my app?

I am trying to add a "New" button and a "Search" button for my app onto the Touch Bar. In system apps, these are a plus sign and a magnifying glass, respectively. Is there a way to use these system icons on my touch bar buttons, such as in UIBarButtonItems? If not, how can I set a touch bar button's content to be a magnifying glass or plus sign? I am using Swift. Thanks.
Apple provides many system icons that you can use in your app.
The Human Interface Guidelines has a nice visual reference of all of the icons available here. These can be referenced in your app by using the associated NSImage.Name constant (also described in the HIG).
As an example, the new and search images can be gotten using:
let addImage = NSImage(named: .touchBarAddTemplate)
let searchImage = NSImage(named: .touchBarSearchTemplate)
Maybe you could find those icons in the system files, copy them and use them in your application, but I would not recommend it. They are Apple's intellectual property and you are not allowed to use them for public projects.
You should search on sites like flaticon.com for similar artworks or create them yourself.

dynamic button text iphone

If you want to make a multilingual button on a native iPhone app, where it can be one language by default, but based on your settings, show different text on the same button, how would you go about it?
Is it also possible to style (e.g. with text-shadows and custom fonts) the text on the button?
I'm not an iOS developer, but I'm attempting to provide designs for an iOS developer and don't understand the limitations (yet) when going from CSS3 to iOS UI elements.
So far, iOS development appears to be like creating image-maps where none of the CSS logic is applicable from web development and almost all UI elements appear to need all states as flattened images. I thought the controls were more dynamic but haven't found the right terminology for results from google to be very forthcoming on the topic.
U can use NSLocalizedString for multilingual text on button.
Configuring Button Title
titleLabel property
reversesTitleShadowWhenHighlighted property
– setTitle:forState:
– setTitleColor:forState:
– setTitleShadowColor:forState:
– titleColorForState:
– titleForState:
– titleShadowColorForState:
Also set Custom font like this:
yourButton.titleLabel.font = [UIFont fontWithName:#"Courier" size:22.0];
if u want to add gradient to button then u will have to use CALayer like this:
yourButton.layer = //any modification in button's layer here
For more refer UIButton class reference

Make Popups With Cocoa Touch

I'm trying to make a popup like in "Camera+" or "Tweetbot" (like this one : Tweetbot or this one Camera+). How can I do this ?
That component is generally called a Popover or a Callout. Apple provides you with an Implementation on the iPad (UIPopover) but not on the iPhone.
There are a few Libraries which attempts to solve this and creates similar popovers like the ones you've shown. With a bit of customisation you can get it to look like this ones you've linked. Below is a list of the ones i've found so far:
WEPopover
CMPopTipView
PopupView
There's similar question here: iPhone popup menu like iPad popover?.
There is a solution. It's called WEPopover and you can download it from github.
For ipad use the popover control:
http://www.matthewcasey.co.uk/2010/04/07/tutorial-introduction-to-pop-over-control-on-ipad-part-1/
http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/iPadControllers/iPadControllers.html
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html

How to Apply Style to Iphone application

I like to have uniformity in my application style for my mobile.How to apply the styles to my control in the Iphone app ..Something similar to android resource files.. Even i hope thats one of the good pattern to follow in the application develovpment
Buttons can be styled by using
creating a custom button.
Custom views can be created using Interface builder or via code inheriting the UIview. A sample tutorial can be found here
You can create custom uitableview and uitableview cells too.
Resource files in android application is what Interface builder provides you in Xcode to create xib (nibs) for your ui layout.

1Password Style custom Action Menu

I just have a quick question. In the 1Password app on the iPhone/iPad when you tap the password field it gives you a non-standard option in the context-menu. I was wondering how this could be recreated with some other non-standard options like "Copy/Email/Something else".
** This does not pertain to passwords and text masking
Custom Action Menu Options http://cl.ly/b8e92af85937086308f3/content
On the iPad, and on the iPhone running OS 4.0 or later, you can use UIMenuController class's menuItems property. If they're doing the same thing on iOS versions prior to 3.2, then it's probably a custom-built view that just looks like the usual context menu.