How to make a round WKInterfaceButton in watchkit? - 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.

Related

text in component does not auto-resize border-box

I want to set up a component with a coloured background rectangle and a text, that is ready to be resized in width and also automatically resizes its height based on the length of the text.
For now I can only resize the height of the component manually, but would prefer if the component can do this automatically, like HTML does.
I added a constraints top, left&right to the text layer. And constraints top&bottom and left/right to the background layer.
Have a look at the component, the current and expected instance.
Does anyone have a helping hand on this?
Press F then click/drag to create your colored background rectangle.
Press T to create your text layer inside the frame and add constraints to it as follows: top & bottom and left & right.
Select Auto Height in the right-side panel under Text.
See detail.
Readjust the width of the text layer to your preferred size and center it inside the frame.
Select the frame layer (parent) which should contain the text layer inside of it (child).
Press Shift A to transform the selected frame into Auto Layout. Notice the icon changed.
Now, to resize, select the text layer and drag ā€˜nā€™ drop.
See result.

How to position buttons according to background in Android?

I'm making an app that needs the following background. Trouble is, I'm not sure how to position the three buttons inside the circle.
Use LinearLayout(vertical), put all the buttons there and use the View subclass called Space, above, inbetween and below the buttons. Then adjust layout:weight until you get the desired proportion. Don't forget to set height to 0 for layout:weight to take effect.

Highlight image regions on hover with CSS

What is the HTML CSS solution for highlighting specific areas of a map/floor plan like this?
http://www.centrecourtshopping.co.uk/store-info/
They use sprite image look here.
Basically, it works like that:
The map with dark-blue regions is completely static.
There is invisible layer on top of it made from small rectangular in their case <a> -- each corresponds to single dark-blue region and posses its its own id.
When cursor is placed over a rectangular with id x the sprite image is nicely aligned with its background (by setting CSS's background-position).
Do not think, this magic would be possible without using JavaScript.

Rounded map corners hide streetview close button

I used css & corner images to get rounded corners on a map but when showing streetview the close button is under the image and can't be clicked. Anybody have any ideas?
I ran into this problem recently... I created a "frame" (ie: a div that acts like a like a "picture frame" that sits perfectly on top of the map div; position it absolutely if you need to) and apply the rounded effects and corner images to the frame instead of the map div.
Alternatively you could experiment with wrapping the map inside a parent div with overflow hidden.
I ended up binding an event to the top right div to close the street view on click.

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