How to create rounded images with WatchKit? - ios

I'm trying to do a rounded images to be shown in my WatchKit application but I don't find any method to do it programatically.
What I have done to perform that, it is use my original image as a group background and put inside a mask image with rounded shape but I think this is not so clean.
Another different solution that I have thought is to create in my backend a new thumbnail or similar with the shape I want to show, but this require more time to be programed.
I could use also radius parameter from WKInterfaceGroup but, in my case (see the image below), I will lose my notification bubble that I have in a corner.
My app interface:
Uber application example:

Put your WKInterfaceImage inside a WKInterfaceGroup and round the corners of the group in Interface Builder.

What you are trying to create is not possible at the moment (we'll see if Apple will add new features to WatchKit this Summer). You'll need to mask your icons on your device and cache on your Watch.
As 'bgilham' said you could put the WKInterfaceImage inside WKInterfaceGroup, but you don't have to. You can just set the background image of WKInterfaceGroup. This time you can create some shiny fake subviews. WKInterfaceGroup inside WKInterfaceGroup with different background images on them.
For example. Lets say you have three ui (WKInterface) elements 'iconGroup', 'badgeGroup', 'badgeLabel'.
Center badgeLabel inside badgeGroup. Set badgeGroups radius to half of its height. If badgeGroups width is equal to its height you'll get a nice circle. Place your badgeGroup inside iconGroup at the top right corner. You can now set the radius of iconGroup equal to the radius of badgeGroup. Set the background image and you'll get a nice rounded rectangle with an dynamic badge.
You also can hide some items (groups) and fake some dynamic changes inside your watch app. There is tons you can create with such fakes. If you will add some animations (for example .png files) you can create fake views with transparent overlays and so on.
UPDATE:
I checked the uber screenshots of uber app, because I was wondering how they created that overlay over the map. My only clue is that they creating a lot of images on their iPhone and sending them to the apple watch to animate the background image of the WKInterfaceGroup. If the images are cached they will play 30fps on the watch otherwise its going to be 10fps or so.
My statement:
So rethink your design, its not always good to make a design like everyone else do. Create something shiny and new so people will memorize your work. :)
Hope this will help you guys out there to rethink your work and create some cool watch apps. Day one apps aren't that great at all, only a few of them are.

You can actually achieve this by using three groups:
The 1st WKInterfaceGroup has your original non-cropped image as its background.
The 2nd WKInterfaceGroup, which is inside the 1st one but has the same size, has the circle image mask as its background.
The 3rd WKInterfaceGroup, which is inside the 2nd one, contains your badge. You can put the text label in it.
Although this requires a pure simple background so the mask image can simply just overlay above the background image, this one doesn't require any image data transferring between the phone and the watch.

The only way to do this right now is just as you said. To mask the profile image into a circle, add it to a group, then add the notification bubble group as a sub-group of the main one (with a circular radius and the label inside.)
Right now there is no way to have a sub-group ignore its parent's clipping radius.

i have used UIImage category from http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/.
this has a Category for Rounded corner images, worked for me in watchkit app.

Related

How to add a gradient background with LaunchScreen.storyboard?

I want to add a gradient background to LaunchScreen.storyboard.
Since this gradient changes with the diagonal of the screen, it is difficult for UIImageView to support screens with different aspect ratios.
So far, Launch Image was used to solve this.
However, Apple enforces the use of LaunchScreen.storyboard.
How do I add this to LaunchScreen.storyboard?
Thanks.
Use an image editor (or whatever suits you) to create that as an image.
You can then add a UIImageView to your LaunchScreen.storyboard (Content Mode: Scale to Fill).
Edit
LaunchScreen storyboards cannot execute any code - and that includes trying to use a custom subclass.
If scaling a single image doesn't suit your needs, you do have a (limited) option.
UIImageView - including when used in a LaunchScreen - can have different images for different size traits:
You cannot get down to actual screen sizes, but using different images for the different trait combinations might do the trick.

Minimimtrackimage alignment issues in swift

I’m trying to create a waveform player similar to soundcloud, the minimum track image I set for the slider originally kept stretching to the slider button itself. I wanted it perfectly aligned with the maximumtrackimage so I users the code:
Image.ResizableImage(withCapInsets:UIEdgeInsets:0,0,0,0)
Screen shot
Which made the image stretch out past the slider button to the whole slider track itself, which is what I wanted but the problem is that the image is passing the slider track and I want it to resize from the beginning of the slider track to the end.
I can't quite remember what the SoundCloud interface looks like, but I seem to recall it's something like this:
I generated that effect easily without using any slider. In general it's probably best to do things the easy way, constructing your own interface rather than trying to bend some existing interface element (such as your slider) to some purpose for which it was never intended.
My interface consists of two image views, a red version of the sound "wave" with a black version laid on top of it. The "transition" from black to red is performed by sliding a layer mask sideways over the black version of the image view, thus revealing the red version which was hidden behind it.
So all you would have to do is coordinate the position of the layer mask with the position being played within the song. If you wanted to use this as a scrubber, you would just detect the user's finger within the image view and do the same thing.

Position image without autolayout

I hope this question makes sense.
I have 2 images in my viewcontroller. One is for a background and the second I need to move around on top of that image freely. I am using autolayout for the background image, but when I test on different devices the second image is not in the proper place because I am not using the autolayout on it and therefore it does not move correctly.
How can I move the image to be in the proper place. Is there some way to set it properly in code. I guess I mean how could I set the autolayout in code since this image will have many positions it needs to move to.

watchkit image on top of image

How to put an images on top of another image based on model?
Ideally I'd like to have an image, what has positioned images and labels on it. If I use a group I could only post them one after another.
Cheers
You can create a group, set the background image of the group, as described here Apple Watch set background image, and then add your foreground image and labels to that group

Apple watch circular buttons

How to design circular buttons in Apple watch? What would be the approach to design a screen like the contacts application of the watch.
I don't know if this is what you want, but you could try this:
-open your Graphic/Design-Application (Photoshop, Gimp or whatever)
-create a circle-button and save the image
-in Xcode, drag a button into your interface
-go to the attributes inspector of the button and set your image at background > image
You can achieve this using group,
Drag group object and drop it in interface builder
set equal height and width to the group
In attribute inspector, set custom radius to half of the height value set.For Eg: if height and width is set as 30, then the radius will be 15. This will give you round shape.
Add color or image based on the need
Add tap gesture to the group and add action to the gesture. Handle stuffs here that are needed to be handled on clicking it
Please, find my answer for your query. I hope that it will help you more.
If you want to design a screen like favorite contact app on apple-watch, then the WWDC video link given in my answer will definitely guide you.
I have designed app with a circular menu which is not exactly same as the apple's favorite app, But it has almost have a circular view with statically.
For that, I have used Groups in horizontal layout for each horizontal item with proper alignment of inside groups.

Resources