Watchkit App: slider background color - ios

I am surprised no one asked already this question, maybe I am just thinking something wrong. But here it is: I am trying to use WKInterfaceSlider to show some progress. The background of my app is black and I really need the background of the slider to match. It looks really bad with that dark grey default background. Isn't there really anyway to set it to replace it or simply set it to nothing?
I would accept also a no answer, but I would really like to understand why this choice in the APIs.

It seems you are unable to set the background color of the WKInterfaceSlider. You could always do a feature request.
I think the reason behind this is that the user should be familiar with the interface elements regardless of which app he/she uses.
Tips:
You could make your own Slider via a WKInterfacePicker. Where you define the slider as an image sequence. Highly customisable and you could slide it via the digital crown.
Check out this piece of code: Trying to get button to spin in WatchKit

Related

Swift Multiple Alert Dialog Fade Out my Interface to Black

Goodmorning all,
In some cases I need to present a lot of alert dialog (overlapped on each other). At the moment i can't find another way to do this because i need to take trace of each user's answer for each question in my dialogs.
So, after 5-6 dialog overlapped i've something like this:
my interface is faded out till to black, there is a way to avoide it?
Thanks all in advance.
That happens because the alert has a slight transparent black background which appears on top of the view. The things is since you add a lot of them, at this point this translucent backgrounds they get combined and you get the non-transparent black one.
One alternative would be to not present the alerts all at once but in sequence. So when the first one is dismissed, you present the next one and so on.
Another alternative would be to write your own custom alerts. Then you could control the background as would be fit your application.
However, it does not seem you are using the alerts for what they are supposed to be used, which is errors or messages the user must know. Maybe there is another solution for you application, maybe using a form or something similar. They are quite an intrusive way to interact with an application, so they should be used accordingly.
Hope this helps and you get to figure out the best solution for your project. Good luck!

Update status bar text colour in real time as view changes

This might be a beginner question, but I noticed something interesting in the new Apple Music app. When switching from one view to another, the status bar text colour seems to change in real time rather than all at once when the next view loads.
Check out this screen recording to see what I mean:
http://f.cl.ly/items/2A0a3Q3i2O2d2O3u3q1m/statusBar_1.mp4
Closeup: http://f.cl.ly/items/182r3n3Z1m1y0y1W0j2J/statusBar_2.mov
How would I achieve this same effect? For instance, when transitioning to another view controller modally, how would I get the status bar style to change dynamically like this rather than when the next view loads? Is it even possible? Is Apple using some private API, or is it just a really simple trick I'm missing? Sorry if this is a beginner question, but I don't think I've ever seen another app do this.
Nothing you’re missing—there’s definitely no API to do that. I’ve seen a couple of third-party apps do something similar, probably by finding the status bar window, snapshotting it, and doing clever things with the resulting image, but that’s pretty fragile. As always, if you’d like an API for something, you should file an enhancement request.

What would be the most efficient way of implementing a dark mode in my application?

I have an application that I want to shift to night mode when a button is pressed. What would be the best way of doing that?
I was thinking of creating a class of light vs dark colors to use for certain labels as well as a notification firing when the button is pressed to notify all of the app to adopt the colors. Is there a better way of doing this?
So to set the color, you need to set the properties tintColor or barTintColor or something like this. But I think the real question of yours is, how you can effectifly switch between the two modes.
Your idea with the theme manager class that fires a notification is not that bad, another option would be to observe for theme changes. But firing a notification might be even better.
In this case you only need to listen for the theme-changed-notification inside you UI-subclasses and change their color if the notification fires. And don't forget to remove the NSNotificationCenter-observer in your dealloc :)
If you are building a web application you can use only CSS to implement a light- switch function.
This page looks exactly what you are looking for.
(It also has a CodePen demo.)

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 make a slider volume controller on iOS? Objective-C, iOS 7 (or 8), xcode 5 (or 6)

I am learning to develop iphone apps and I have a simple question.
I am making a really simple app which allows the user to set the volume of the device on the settings screen using a slider instead of the volume buttons.
It may be quite obvious for experienced developers but I just can't find the answer I am looking for.
My question is:
How can I make this slider?
Basically I want to do this (image: https://www.dropbox.com/s/b81bzdwyrab0ha7/slider.png?dl=0):
I used to think that I could use a regular UISlider but some documentation says that I need to use something called a MPVolumeView. The problem is that I can´t find a good tutorial that tells how to use this explicity.
I found this link on the apple documentation but I dont understand how this works. – http://developer.apple.com/iphone/library/documentation/MediaPlayer/Reference/MPVolumeView_Class/Reference/Reference.html
And the description says: Use a volume view to present the user with a slider control for setting the system audio output volume, and a button for choosing the audio output route. When first displayed, the slider’s position reflects the current system audio output volume. As the user drags the slider, the changes update the volume. If the user presses the device volume buttons while sound is playing, the slider moves to reflect the new volume.
This is exactly what I want but I dont understand the example it gives. If you could please tell me how t make this slider work, even if it is on a new one-view project, I would really appreciate it.
Also I am aware that this method also creates an airPlay button next to the volume slider. Is there a way to delete this button? (My app is a simple productivity app so I only want the slider, not the airplay button).
I also understand that this will not work on the simulator. How am I supposed to know that this will work without having to test it on an actual device (I am not registered as a developer yet)?
Plus, I only know objective-c, not swift. If you could please restrain from using swift in your answers I would apreaciate.
Thank you so much for your help.
PD: English is not my first language. Sorry for any mistakes I made.
The MPVolumeView class is designed to let you do exactly this. It's in MediaPlayer.framework, so add that to your app to make things build correctly.
You create it and make it visible the way you instantiate any other subclass of UIView, which you probably know by now.
You disable the routing button by setting the "showsRoutingButton" property to false.
"How am I supposed to know that this will work without having to test it on an actual device?"
By seeing that it's been there since iOS 2.0, and is used in countless apps?
The process to writing such a slider is incredibly simple, look into UISlider(https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/) and then use the float value from the slider to set the volume.
If you do not want to write your own slider, look on GitHub(github.com) for controls that do this for you. After doing a quick search, I found this UISlidersubclass that adjusts volume.

Resources