0

I have a custom table view and want it to look like this...

a busy cat
(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.

1
  • I think you can do all that in the storyboard file with constraints. You will probably need to insert the gradient as a transparent image, to make it easier. Where are you having problems exactly? Commented Mar 31, 2014 at 16:32

1 Answer 1

2

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.

enter image description here

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.