Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-29-2008, 01:51 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 31
svjim is on a distinguished road
Default Align Multi-line UILabel

I have a multi line UILabel which I want to align with some other single line labels. The problem is that I cannot get the label to fill from the top left hand corner of the labels bounding rectangle when the text being displayed is less then the maximum number of lines that I have specified. It always wants to start out in the center of the label. Is there any way around this?

Thanks Jim
svjim is offline   Reply With Quote
Old 10-22-2009, 04:25 PM   #2 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 3
JerryWho49 is on a distinguished road
Default

Quote:
Originally Posted by svjim View Post
I have a multi line UILabel which I want to align with some other single line labels. The problem is that I cannot get the label to fill from the top left hand corner of the labels bounding rectangle when the text being displayed is less then the maximum number of lines that I have specified. It always wants to start out in the center of the label. Is there any way around this?

Thanks Jim
Did you have any solution for this problem? I'm having the same one
JerryWho49 is offline   Reply With Quote
Old 10-23-2009, 02:03 PM   #3 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Dutch will become famous soon enough
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by JerryWho49 View Post
Did you have any solution for this problem? I'm having the same one
You might need to calculate the height of the textField based on the width, and size its frame accordingly. That is how I accomplish that... I used this method to do it.

Code:
-(CGSize) calcLabelSize:(NSString *)string withFont:(UIFont *)font  maxSize:(CGSize)maxSize{
    return [string
            sizeWithFont:font
            constrainedToSize:maxSize
            lineBreakMode:UILineBreakModeWordWrap];
    
}
Dutch is offline   Reply With Quote
Old 01-17-2010, 02:04 PM   #4 (permalink)
Registered Member
 
Join Date: Sep 2008
Posts: 149
ThirtyOne is on a distinguished road
Default

Very helpful. Thanks.
ThirtyOne is offline   Reply With Quote
Old 05-26-2010, 02:46 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 2
ajdavis is on a distinguished road
Default UITextView

An easy way to use multiline text aligned top-left is to use a UITextView instead of UITextLabel. Just make the UITextView non-editable and disable its scrolling; it'll be multi-line and aligned top left by default.
ajdavis is offline   Reply With Quote
Old 06-21-2010, 08:55 AM   #6 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 5
ashrafulkarim is on a distinguished road
Default

If i make the text view scrollable, it seems the top/vertical alignment is not working. do you know how to fix it?
ashrafulkarim is offline   Reply With Quote
Reply

Bookmarks

Tags
align, multi line, uilabel

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 336
11 members and 325 guests
bignoggins, carlandrews, flamingliquid, hzwegjxg, ilmman, jenniead38, linkmx, nadav@webtview.com, stanny, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:50 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0