Programmatically add a border to WKInterfaceGroup - Solved - objective-c

Is it possible to give a WatchKit table cell or WKInterfaceGroup a border width of 2px and a red border color? If not, are there any work-arounds?

It can't be done programmatically, but you can give the impression of a boarder in IB.
Add a separator above and below the cell's sub-group.
Give the cell's main group a background color.
Make the first separator an alpha of 0 and a top vertical alignment.
Give the cell's sub-group a center vertical alignment.
Give the second separator an alpha of 0 and a bottom vertical alignment.
I'm pleased with the result.

Related

TableView with inset grouped style: Have rounded corners even with hidden cells

I have a table of the type inset grouped style. Depending on some selections I want to hide some cells by reducing their height to 0. Now is there anyway to still show rounded corners even if the respective cell has height 0? Or how would you do that? I don't want to "delete" the cell, otherwise it is much more complex to keep track of the cells for me.

QlikView - Bar Borders

I have a grouped bar chart in QlikView - the bars are displayed in different colors. Is it possible display the last bar in a group so that the border of the bar is red, and the middel of the bar is white?
Short answer; you can't do what you want to do.
You can individually set the thickness/presence of the bars but you can not change the colours of those borders. You will also need to set-up an expression for each you can not affect the border thickness based on the dimensions
And you can colour the bars as per the dimension quite effectively, so without bothering about the borders you can make the last bar always red, you just need to know the dimension you are working with
So this:
Will give you this:
Unfortunately not, within the bar chart object bars do not have a border.

How can i achieve Multiline UILabel with NSLineBreakByTruncatingMiddle and sizeToFit in autolayout?

I have a two line UILabel. I want its line break mode NSLineBreakByTruncatingMiddle. The problem i am getting is if text is small enough to fit in one line, its showing it in middle of label instead of at top. I am using iOS6 and autolayout so sizeToFit is not working for me.
How can i achieve this? I want if text is small to fit one line it should be vertically top aligned. I have tried this, but its truncating and showing the text in one line only rather than two line.
You need to calculate the required size and update the frame of your label:
CGSize s = [myLabelString sizeWithFont:...
constrainedToSize:CGSizeMake(..., MAXFLOAT)
lineBreakMode:NSLineBreakByTruncatingMiddle];
With whatever font your label is using and its width.

AQGridView: How to adjust UIGridViewCell margin

I'm trying to implement the AQGridView in my iPad app. Please see my below image -- sorry for the strong colors, but I think it would help you understand my problem.
Each cell (the blue box) has a margin left and right (yellow color), i.e. 8 pixels. This means that the first yellow coloum has a width of 8px, the second 16px, third 16px, and the last 8px. That's maybe fine in some situations, but I would like the yellow columns to have the same width. In my example the total width of the columns are 48 (8+16+16+8) so instead I would like each column to have a width of 12 (48/4). How can I change the AQGridView to do this?
I've tried to change the frame and bounce the AQGridView, but that did not do anything.
AQGridView actually takes the container view's coordinates and creates a strictly-defined grid from that. So when you have a 768px-wide grid view, and items which are a little under 1/3 of that in width, then it will create a rigid grid in which to place these items. By default your AQGridViewCell views will be centred within each grid square (although you can call -setResizesCellWidthToFit:YES to change that); you can adjust that positioning by implementing -gridView:adjustCellFrame:withinGridCellFrame: in your AQGridViewDelegate implementation.
In your case, every single cell has a margin of 8px on its left and right sides. On the outer edges this is seen alone, but in between pairs it appears doubled to 16px (8px from each cell).
What you want, then, is for each cell to have a 6px margin, and for the grid itself to have another 6px of margin space to the left & right of all cells. There's an API for this:
#property (nonatomic, assign) CGFloat leftContentInset;
#property (nonatomic, assign) CGFloat rightContentInset;
What you should be able to do is set myGridView.leftContentInset = 6.0; and myGridView.rightContentInset = 6.0;. The grid view will then lay out cells with a content width of 756px instead of 768px, which should give you a 6px margin around each cell. Combine that with the 6px left & right content insets and you'll have a clean 12px visible margin between every cell and the outer edges of the grid view.
Side note: the content inset properties were actually created to assist with laying out a certain number of cells per row. For instance, 1024 doesn't divide by 5, so it could end up with some fairly small cells being quite spread out since the layout grid would only contain 4 items in width. However, by adding left & right content insets of 2px each, the view would use a width of 1020 to calculate its layout grid, resulting in 5 cells per row. This is, in fact, exactly what we do in the Kobo iPad app when rotated to landscape mode; without that change, our portrait-mode 4 items per row just got spread out & it looked a little too sparse.
I managed to gain more control on the horizontal and vertical spacing by using the portraitGridCellSizeForGridView method and returning a slightly large CGRect compared to the one I used to initialise the cell in the gridView:cellForItemAtIndex: method.
I hope this helps.

How to create a UITableViewCell as those in Contacts app?

How do you replicate a cell such as the one sin the Contacts detail view? The have a "prefix" static text in blue followed (on the same line) by an editable text in black.
They are just using a custom tableviewcell with a blue label for prefix, black label for text and a custom background image. The background image will be different depending on where it is located in a group:
only cell in a group (rounded top and bottom)
first cell in a multi-cell group (rounded on top, flat on
bottom)
middle cell in a mult-cell group (flat on top and bottom)
last cell in a multi-cell group (rounded on bottom, flat on top)