WatchKit group: with image and label, image gets 2 of 4 corners rounded - ios

I'm trying to lay out a view in WatchKit with an image and a label side by side.
I create a Group with a Horizontal orientation, and add the Image with left justification and a label with right justification.
I actually get two different problems here:
(1) My image is square, but the edge of the image that is against the edge of the group gets rounded off. So I have two rounded corners and two square corners, which looks bad. I'd prefer to get 4 rounded corners -- but mainly I just need it to be consistent.
(2) My label text is long and needs to be wrapped. In the Interface Builder I set lines to 2, and in IB it wraps properly. But when I run it, the view in the simulator doesn't wrap, and instead is truncated.

Do you have a corner radius set on the containing group? If so it will clip the corners of the image.

Related

How to create top and bottom corner radius different on WatchKit?

I need to set a corner radius to 6 on top of WKInterfaceGroup and set to 0 on bottom.
Is there a tips or anything ?
Thanks
Example : http://imgur.com/aDASBNy
Since many elements (images e. g.) can't be given a border radius in watchOS, you should use groups with images as their only element. In order to achieve two different border sizes, try using two groups with two different border sizes which overlap themselves, so that one side of the border isn't visible because it's overlapped by the other group.

use an xcode layout constraint to place a display element within another display element

The Apple Documentation has shown me how to place constraints between objects that are apart from each other in the view, like here. However, what if you have a display element that is contained inside of another, as shown below:
Is it possible to set constraints that will "trap" the gray square within the red square?
Make sure you have set the necessary constraints for the red box and place the gray box inside the red box.
Red box constraints:
In my case i want the red box in center of the screen with fixed width and height.
Gray box constraints:
Trapped inside the red box with the distance of 64 all side.
You can make the gray square a subview of the red square, then constrain it to the red square, which will be its superview.
The specific constraints would depend on how you wanted the gray square to size itself in relation to the red square.

How do I solve this Auto Layout "puzzle" with constraints?

On the left is the normal state of the layout. On the right is the expanded state of the layout.
My problem is that I can't figure out how to keep the pink boxes centered within their cells, and the green lines connected between the pink boxes as the layout grows in any direction.
The AutoSizing.xib with just these two views can be found here: https://dl.dropboxusercontent.com/u/6979623/AutoSizing.xib
There are two approaches to keeping the pink boxes centered within the four quadrants of the super view:
You can add four invisible views that even split up the four quadrants of this main view (using constraints to pin them to their respective corners and another set of constraints to make them equal widths and heights). If I were going to represent that in VFL (just because it's a concise way of representing all of those constraints), it might be something like:
H:|[quadrant1][quadrant2(==quadrant1)]|
H:|[quadrant3(==quadrant1)][quadrant4(==quadrant1)]|
V:|[quadrant1][quadrant3(==quadrant1)]|
V:|[quadrant2(==quadrant1)][quadrant4(==quadrant1)]|
You can then center the pink views in the center of each of those four quadrant views.
You can add center constraints that employ multipliers to offset these pink squares within their shared superview. Interface Builder has only recently gotten multiplier support and it's not super solid, in my opinion, so when I want to use multipliers, I often fall back to adding those programmatically.
Once you have the pink boxes laid out correctly, then the green lines between them are simply fixed spacing leading/trailing or top/bottom for horizontal or vertical lines, respectively. Combine that with fixed width and center alignment and you're done. Bottom line, take care of the placement of the pink boxes, as discussed above, and then the creation of the green lines becomes pretty easy.

draw an coloured rectangle in CPTAxisLabel (core-plot)

What I want is to draw a small rectangle inside an CPTAxisLabel to display a colour, what I have all ready tried is to draw a rectangle in a layer and add it as sublayer, but it stretches the small sublayer all over the label and the text isn`t visible anymore, I also tried to make an CPTLegend and add it to the label but I did not found any method to position it in the right side of the label, it just sits in the center, I tried changing the legends position, frame, bounds, padding and nothing. Does anyone know a better way of adding a rectangle shape in an CPTAxisLabel and also keep the text in the label ?
I assume you're using a CPTTextLayer for the label's contentLayer. Use an image fill on the text layer that contains your rectangle. Make it a stretchable image and set the stretchable area to the right of the rectangle. Set the paddingLeft on the text layer to leave room for the rectangle to the left of the label text.
After some long researches I found issue 266 in core-plot and it seems to be the problem I have with positioning a sublayer inside a CPTAxisLabel... I will keep waiting for a fix, but I don`t know if it will be solved soon.

Custom UiTableView from array data

I have a custom table view and want it to look like this...
(source: pulsewraps.co.uk)
The image is loaded via async and the two lines come from two different arrays. I can get all the data in fine I just don't know how to lay it out.
I want:
the black gradient to overlay the image
the two lines of text to be within the black gradient box
the image to fill the table row to cover it and keep it's aspect ratio
the black gradient box to be pinned/constrained to the bottom of the image so that is either line of text is larger than two lines it covers more of the image and doesn't drop below it.
I fill the table data in a loop according to the number of records in my array which is populated by json.
I have managed to do the layout in android but can't get my head around ios.
Any help much appreciated.
If you're using autolayout, you'll want to constrain the labels to the bottom and to each other. Then put the gradient view behind the labels and constrain the top of the gradient to the top of the top label.
You'll have to handle drawing the gradient yourself, either use an image in an image view and set it to scale to fill, or subclass UIView and add a little bit of code to drawRect: The first is probably easier, the second will produce a more uniform gradient if it has to be scaled.

Resources