Change UISwitch Image - ios

I'm creating a toggle feature. Everything is working exactly how I would like it to. My ONLY issue is changing the image to one that's more fitting for my app.
Here's what I have:
https://res.cloudinary.com/dfd4ae1lw/image/upload/v1530126510/Stackoverflow/off_switch.png"
https://res.cloudinary.com/dfd4ae1lw/image/upload/v1530126510/Stackoverflow/On_Switch.png
THIS is what I want:
https://res.cloudinary.com/dfd4ae1lw/image/upload/v1530126510/Stackoverflow/On_Toggle.png
https://res.cloudinary.com/dfd4ae1lw/image/upload/v1530126510/Stackoverflow/Off_Toggle.png
How do change the image of the UISwitch? There must be a way... right?

Apple removed the ability for users to specify a custom UISwitch image in iOS 7, implicitly for policy reasons. So there is no direct way to achieve what you want.
You can simulate it with an NSButton by toggling the isSelected state; this is entirely distinct from the isHighlighted state that relates to user interactions and the interface designer allows you to specify different images for different states.

Related

iOS Accessibility – Detect if Colour Filters is on?

In iOS, you can set Colour Filters which is helpful for Colour Blind users. Is it possible or any way we can know if this is turned on / off?
The documentation does not mention such a thing and there is no UIAccessibility boolean that returns whether color filters are enabled (unlike for inverted colors), so it's safe to assume that there isn't a public API to detect this from an app.
However, this isn't necessarily a problem. Use color schemes in your app in a way that won't distract or confuse users with visual disabilities in the first place.

Can the iOS8 InvertColors function be called in an apps code?

iOS now has a setting in General, accessibility, "Invert Colors". It basically provides a negative image of an app's colors.
I have an app that is mostly dark background elements with light icons and buttons. It would be great to have a setting inside my app to call that invert colors function as needed for specific users.
Any ideas if that setting is exposed? Thanks much!
In general you have no access to the user's Settings, and this is no exception. Your app can't alter general settings on the user's device; that would be a terrible security hole!
However, nothing stops you from putting up an alert or other dialog suggesting that the user might like to do this.
Alternatively, though, what I would recommend is themes. Basically give the user a preference within the app, so that the user can choose or alter the colors of things. Then, in response to the user's setting, you use the appearance proxy to change all the colors thematically throughout the app. There was a good WWDC video either in 2013 or 2012, I think, on this very idea.

How to set background colors in run-time?

I am using GeneXus for a Smart Devices project.
I have to create a grid that will present data from a webService.
This webService will also return the RGB code that represents the background color in which the returned record should be shown.
The only way that I know of setting the background color (on the GridTable) is via the Theme class.
Is it possible to do this in execution time?
There is currently no way to change the background color in runtime, you can only change the theme class.
If the set of colors that will be used is known at design time, you could create a theme class for each one of them, and apply the corresponding class in runtime.
Otherwise, the only solution I can think of is creating a user control to extend the current grid functionality.

using default iOS camera button as a UIButton

I am a newbie at iOS development so please be kind.
I want to use the default camera button as a UIButton. (I want the camera button to be displayed against a field in my form and want to use the default graphic because users are familiar with it)
I don't see any option to insert it as a simple UIButton, I don't want it in the toolbar.
If it's not possible to include it this way, can I use it's image as UIButton? Or it can cause any objection in the app review?
You can use UIKit Artwork Extractor project to get internal iOS images from simulator, but I'm not sure if it's legal to use these images.
There are some examples:
PS:
You also can get a third-party icon for your needs, e.g. from http://www.glyphish.com/
You can use UIBarButtonSystemItemCamera from UIBarButtonItem. It is a UIBarButtonItem, not a UIButton, but it is the real deal.
I ended up using a custom graphic which we owned to avoid any possibility of legal issues or app rejection.

Sticky buttons on iPhone program

Hullo,
I have an app view rather crowded to insert the necessary switches in order to toggle 6 values associated to icons. So I would have appreciated if it were possible to make them sticky buttons, namely to have them independently keep the pressure when clicked in order for me to read the ones in that state when exiting the view.
I read there exists such a technique for Mac but that does not translate to iOS. Hw could I do that?
Thanks, Fabrizio
It sounds like you're looking for a checkbox functionality. Have the button change images when it's pressed, then use that to determine its state.
I'm on my phone so this took a bit, but here's a link to how to make a checkbox in objective-c What is the best way to make a UIButton checkbox?
Note that you don't need to use normal checkbox images.

Resources