How can I set the backgroundColor of a WKInterfaceController programmatically? - watchkit

I couldn't find any way of changing the overall background color of the Watch app interface programmatically.
I therefore tried creating a fullscreen WKInterfaceGroup and changing the backgroundColor of that.
centralGroup.setBackgroundColor(UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0))
However, I still have unfilled rounded corners and lines on borders.
Is there any way to achieve my goal, of an edge-to-edge background color that fills the screen?

While you can set a background color for a WKInterfaceController in the storyboard, there is no API that lets you programmatically set it in the present Xcode 6.2 beta 3.
However, you can create a full screen WKInterfaceGroup and set the color of that programmatically. If you also setCornerRadius: to 0 you get the following result:
Clearly, there are still black lines at the edges here. The other possibility was that setting a solid color image as the background might perhaps scale to fill the full screen with one of the scaling options, but I tested this and the result is identical to the above.
However, it is important to consider the hardware this will be running on. Apple have said more than once in their public statements about the Watch that the intersection between the laminated screen and the edges is so seamless that you essentially can't tell where the screen ends and the edges begin. Taking this at face value, as long as you set the background color of the WKInterfaceController to clear or black in interface builder, so that these edges are black to match the screen surround, then these black lines should be invisible to the end user and are something you can safely ignore.

This is how I done it:
Add WKInterfaceGroup and setCornerRadius to 0
Go to WKInterfaceController Attribute Inspector and change Left/Right insets to 0 (Fig.1) (This will remove the extra black line on the left & right side)
Change the color of the WKInterfaceGroup to whatever you want :)
Fig.1

Change insets of Your WKInterfaceController to custom and set all to 0. Also, change corner radius of group to 0 too. Enjoy.

Try changing the corner radius of the WKInterfaceGroup to 0. You can use setCornerRadius: to change the corner radius.

Related

Figma element background color solid not transparent

My Figma element has transparent background but I want to get it solid, simple as that, and I can't find the correct way how to do it.
Which thing in the settings I should check?
To do what you want:
First:
make sure the element fill is 100%, when you are selecting the element layer itself, it's here:
Second:
make sure the frame itself has no grid active, so you can click the minus icon behind the grid section if it's active, like here:
I needed to remove layout grid for the whole page and colors became normal. I think that is so user could see the background grid so he could make the best possible design and then you delete it when you stop developing and your work is finished
Go to the fill section of the items settings and make sure the percentage next to the color is 100% or whatever opacity you want.

A-Frame Canvas texture default color white in VR-mode

I am applying a canvas as a texture to a plane. And it looks fine (The background is white by default) if I am displaying it within a browser itself.
But as I change to Virtual Reality Mode the background of the canvas is changing to black.
I know that i can place a white rect to have a white background, but this is not feasible due to performance issues.
Are there any other solutions to tackle this problems?
Thanks!
Try filling in the canvas as white (fillRect), or adding a background to the scene itself (<a-sky color="#FFF">). Let me know if that works, or provide a JSFiddle for us to play around.

How to make a round WKInterfaceButton in watchkit?

iOS can use layer.cornerRadius to make a round UIButton.
Does WKInterfaceButton have this property?
If not, how can I make a round WKInterfaceButton in WatchKit.
If you put an image inside a group, you can then set the radius of the group. This crops the image into a circle. In the picture below, I have:
Group (radius 56)
Group (radius 52)
Image (a square image)
While this example is with an image, you can use the same technique for a button. Previously the dog was clickable as a button so this is doable.
WKInterfaceButton does not have a corner radius property. You can make a circular button by setting a circular image as the button's background image. You can generate the image in code doing something like this: Draw a simple circle uiimage
You don't need an image to make WKInterfaceButton rounded. Instead:
Go to Attributes inspector for the button, and select content type: Group
Inside the button find the group and set its corner radius to whatever you need.
Scroll down the inspector and set both fixed Width and Height to the value equal to the radius doubled. Here you go
You can put whatever you want inside the button, for example a text label. This way you also can make oval buttons.

Changing stylesheet causes qlabel to move

I have a few labels in a horizontal layout, and I want to enable/disable a border around the labels at certain times. I can do this using stylesheets, but the problem is that every time I enable/disable a border this way, the label shifts left or right in the layout by a few pixels.
This is an annoying artifact that takes away from the look of the UI. Does anyone know how to prevent this from happening?
Thanks!
Marlon
If your labels are on a plain background, then don't enable/disable the borders, just change the border colour to match the background.

How to create a button on our desire shape like circle, star in flex 3?

I would like to customize the shape of the button to different shapes like circle, star, square or of any shape. How would i achieve so?
I apologize because this doesn't answer your question, but:
In order to make sure the user can reliably click on your button, you probably want it to be a convex shape. A rectangle or circle is fine, and you could paint a star on it. But you wouldn't want the user to try to click your star and miss, just because they were not quite inside one of its arms.
Canvas can be used as button.
Take a canvas of required size. Give your required button shape(image) as background image to canvas.
Example:
Explanation: {nextYellowButton} is the embedded button. It is an arrow mark shape button.
It is a .PNG image. So, it doesn't include the background color.
Now your button is of arrow shape. it occupies 50px * 50px area on screen. But it looks exactly like an arrow mark.

Resources