Is there a way to combine two UI elements? - ios

I am developing a mobile app in Swift and I have a custom UIView that displays a circular progress bar, but I want to add a UILabel in the middle that also displays the progress percentage. Is there a way to do this?

UIViews can overlap. You can just put the label on top of your custom view, or you can make the label a subview of your custom view.

Related

UIStackView inside a subview programmatically

I've got a ViewController that has a lot of labels that must be displayed horizontally, so I've decided to use UIStackView for this.
These labels belong to different "sections", so I'm using nested stack views to achieve this. The problem is that one of these "sections" should be displayed with a different background color than the others.
I've read in another thread that UIStackView does not have a background color, and I should add the stack view inside a UIView and set a proper background color to it.
What I've made so far:
Create a UIView and set its color
Create a sub stack view and add some labels to it.
Add the sub stack view to the colored UIView
add the colored UIView to the main stack view.
The result: I'm not seeing any of those views inside my view controller.
Note: I need to do this programmatically.
Thanks in advance!!

Hiding labels in iOS without breaking the view

I know we can use UIStackView in iOS9, but I'm not able to get rid of iOS8 at the moment, so I was wondering if is it possible to hide some labels inside a UIView (plain UIView, UIScrollView and UITableViewCell) and keep the rest of the visible labels "stacked".
Basically I've got some labels "stacked" vertically and pinned to each other by autolayout. If I hide any of them I get an empty space where the label was placed in interface builder.
I've managed to emulate the stackView's behavior using OAStackview, Following these steps:
Subclass ViewController using a UIScrollView and a OAStackView property.
Put the stack view inside the scroll view
Set constraints for these properties programatically
Add a bunch of custom labels to the stack view.

How to set constraints when all buttons are of different size

I have one view on view controller on that view I have six buttons I want to set constraints to these buttons but I am not able to do that. When I set constraints two of them get compressed don't know why.
I am sharing screen Shot,Please help me Thank you
You don't need six buttons for designing above screen. You can do this by using UITableView and custom UITableViewCell.
For more : Customize tableview cell
Or by using three UIViews by sub viewing UIImage and UILable and then add UITapGestureRecogniser to that UIView.
For more : Tap gesture

UIView overlaps UISegmentedControl

In my app, I want to add a UISegmentControl on top of a UIView.They are siblings of a parent UIView.I pull a UIView to the canvas from object library first, and then pull a UISegmentControl second,but unluckily the first added UIView overlaps the UISegmentControl. What I want is that UISegmentControl is on top of the UIView. I mean UISegmentControl z-index is higher than the UIView.
The following is the screenshot.
One potential solution would be to programmatically send either the UIView to the back or the UISegmentedControl to the front in viewWillAppear(animated:) using parentView.bringSubviewToFront(segmentedControl) or parentView.sendSubviewToBack(otherView). It doesn't solve the issue of the incorrect appearance in your storyboard but it ought to fix the issue once the app is running.
1) First reduce the width and height of the overlapping view to understand its location in view hierarchy. Share your view hierarchy here so we can see in detail.
2) Delete everything from storyboard. Add UIView and then add any subviews. These 2 controls should be children of UIView in view hierarchy.

iOS: iMessage style header and divider UI

I'm trying to recreate pieces of the iMessage UI. Specifically the top buttons and dividers (i.e. "iMessage" label + line)
I'm assuming:
The top buttons are within custom UIView as the header of a UITableView
The divider is a custom UITableViewCell with a centered label and some kind of repeated background imageā€¦
Can anyone confirm or elaborate on this? Specifically the dividers.
First, I would create the divider and the "iMessage" text as a single image.
Since the divider and the buttons on top of it is "non-sticky" I would just create a custom UITableViewCell and put everything (buttons and divider image) in the table cell.

Resources