How to add a horizontal line in iOS using StoryBoard?

17,970

Solution 1

You just have 2 options:

  • take an image with the appropriate gradient and insert an image view
  • make yourself a view class, that fills it's view with a gradient (by code)

That's it

Solution 2

In Storyboard, if you don't want code. I recommend following process.

  1. draw a line using a drawing tool (about illustrator, photoshop) and then saved as png.

  2. make a UIImageView your Storyboard and set image your png file.

Solution 3

Use "View" and set its height as 1 or any size you want, and change the background color.

Share:
17,970

Related videos on Youtube

vinothp
Author by

vinothp

Do what you like. Believe in what you do. Young and energetic individual with great passion on Mobile Application Development. Currently working as a full time mobile application developer for Android and iOS. In free time working on personal projects as well. My First Personal App - Location Plotter/ House Viewing

Updated on June 03, 2022

Comments

  • vinothp
    vinothp almost 2 years

    In my app I am trying to create a customized/stylish horizontal line in-between two labels. I have searched in SO and Google but it has only by code. How to add a horizontal line using story board?

    In Android I have designed the below line using XML.

    enter image description here

    How can I create the same line in iOS?

    • Bijou Trouvaille
      Bijou Trouvaille over 11 years
      I don't see what's so difficult or vague about this question. This has to be one more time I'm seeing casperOne on a rampage. One way to make a quick horizontal rule is by placing a 1px high empty label with an appropriate background.
    • Mark Molina
      Mark Molina over 10 years
      Totally agree with Bijou. This casperOne should really try starting to read a question before giving his judgement.
  • vinothp
    vinothp almost 12 years
    thanks for your answer.. is is possible by code if so i am happy to do that as well
  • kmiklas
    kmiklas almost 10 years
    If you're you're making a prototype, in a rush, or using Agile, a quick trick from the good ole' days is just to create a label of underscores or dashes and color appropriately; e.g., ____________________________________________________________‌​______ ------------------------------------------------------------‌​-------
  • Matt Parkins
    Matt Parkins over 9 years
    Another "trick" if you can't be bothered to do any of the above (pure laziness I know) would be to use a thin progress bar set to whatever colour you want, with a progress of 0.
  • programmer
    programmer over 8 years
    Yet another but easier "trick" is to use an empty UILabel with its height set to 1px and set its background color and width to your preference. Hope this helps.
  • maxweber
    maxweber almost 6 years
    @programmer is easiest. Thanks.