How to add a horizontal line in iOS using StoryBoard?
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.
draw a line using a drawing tool (about illustrator, photoshop) and then saved as png.
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.
Related videos on Youtube
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, 2022Comments
-
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.
How can I create the same line in iOS?
-
Bijou Trouvaille over 11 yearsI 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 over 10 yearsTotally agree with Bijou. This casperOne should really try starting to read a question before giving his judgement.
-
-
vinothp almost 12 yearsthanks for your answer.. is is possible by code if so i am happy to do that as well
-
kmiklas almost 10 yearsIf 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 over 9 yearsAnother "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 over 8 yearsYet 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 almost 6 years@programmer is easiest. Thanks.