Search code examples
iosiphoneobjective-cuiviewcontrollerrubymotion

Which view controller should I be using?


I am trying to implement a mockup like this. However, I'm not sure which view controller I should be using for something like this? I tried UICollectionViewController but that puts cells of fixed width on each row. As you can see in my mockup, at some places I have a label taking all width and in other places I have three labels taking up the width.

enter image description here


Solution

  • You can use the simple UIViewController and drag the labels manually in the Storyboard. In order to make the rectangular label to round edged labels, you can create a IBOutletCollection of all those labels and iterate through the array, get each label's layer and set the corner radius to appropriate value. e.g:

     @property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *customLabels;
    

    As customLabels is an NSArray so it doesn't have a layer property. You can do it like this:

      for (UILabel *label in customLabels) {
            label.layer.cornerRadius = 5.0;
        }