align portion of label to right - alignment

I have a label that needs to have a portion of it aligned to the right.
For example if this is the text box:
|left.........right|
If there is no easy way to align right... I have an idea, but I'm not sure it's possible but here it is:
I could calculate the width of the right string by adding the width of the pixels of each character, a fixed width font is ideal. With this I could calculate amount of spaces I need to insert to get the text all the way to the right.

<div style="width:200px">
Left
<div style="float:right;">Right</div>
</div>

Related

How adjust label alignment using autolayout?

I have some labels on my screen.4 Labels can have dynamic value it can display integer number value as well as it can also display some word as START.I have given the following constraints:
Leading to image
Top to image
Now as the text increase there is enough space on left so that label can expand it's width.but as i have given leading to top image so it will not move more to left.So please tell how can i move it to left when text increase.I know i can do it with the help of making outlet of leading constraint and change its value.
But is there any easy way of doing it ?
edit the leading Constraints to "less than equal to" '<=' and trailing fixed '=', whenever the label will have lengthier text its size will increase in the left side and be fixed on the right side

How can I get pixel precision when placing text with Auto Layout?

When using Auto Layout to position a label, I always get very imprecise results. In the example below, I have aligned the top and left edges of a UILabel to a parent UIView:
There is empty space on all four sides of the text, but the amount of empty space at the top and bottom is especially horrible. It is very tedious to take screenshots and figure out how many points I would need to offset the constraint's constant value to make the text line up properly. Is there any way to for the UILabel to properly reflect the rendered text in its frame?

NSAttributedString alignment to particular text

I m trying to align the attributed text of UILabel with multiple lines as below.
The alignment should be like all the days in chars left align and timings right align. How can i do this .Please suggest.
Thanks
I would break the string into 2 and align the day to right and the time to left. Otherwise you need to calculate each letters width (and the spacing between the letter before and/or after.) Fonts are complex as the glyph itself and its spacing to neighbours are different from letter to letter.
I hope there is someone who found an elegant way to do this.
I also had very similar task and here is how I did it.
I achieved this by breaking the line into two pieces.(what should be aligned left and what should be aligned right)
Then on your view create two UILable with the equal widths.
After that display left side in Keys Label and right side in Values label
Do not forget set Lines to 0
Left align your text.
textAlignment = NSTextalignmentLeft
Separate each line with "\n" to force a new line
#"Tuesday 9:20\nWednesday 8:40"

HTML Element alignment using Jquery

I have a table with three columns, the first column takes an image, the second takes a heading label and third is very small and is empty.
The Heading label in second column is being centered to the center of the column but what I want is to center it in the middle of the screen at the same height it is present at. I used jquery window width but couldn't attain the result required. The heading label is made up of two labels.
please help....!
Why you use table.Insted of table use divs.Here i paste the code for that
you want to align the center of <div id="myDiv"></div> to the center of <span id="mySpan"></span> write
$("#myDiv").align({left:{my:0.5,at:0.5, selector:'#mySpan'}, top:{my:0.5,at:0.5, selector:'#mySpan'}});

Right Align Gap in sIFR

When I right align there is what appears to be like a 3-5 pixel padding on the right. But when it is left aligned it is perfectly lined up with the content. Any help would be appreciated.
Try using a negative value for tuneWidth to remove the extra space.

Resources