FAQ Database Discussion Community


Align two labels vertically with different font size

ios,autolayout,uilabel,vertical-alignment,baseline
I have a parent UIView where I place two labels on it. Each of these labels only has one line as can be seen here: The problem now is that the baseline is wrong. I'm using auto layout and the question is how should my constraints should look like in...

how to make a specific fragment of an NSAttributedString a specific color in Swift

swift,uikit,uilabel
I have a UILabel with an NSAttributedString with the following code: // just creating from a notification.mainCopy! var myMutableString = NSMutableAttributedString(); myMutableString = NSMutableAttributedString(string: notification.mainCopy!, attributes: [NSFontAttributeName:UIFont(name: "Helvetica", size: 14.0)!]) // a notification will have a blueMainCopy1 - just a test so no this could be done better // How...

Cell's accessory keeps truncating UILabel

ios,swift,uitableview,uilabel
I just wonder why a UILabel in UICell gets truncated despite the fact that it would actually fit there. I know that accessory indicator takes some space but this is not the point, from what I can see in my storyboard the uilabel would fit there easily. My constraints aren't...

Can't set UILabel Text Programmatically

ios,objective-c,uilabel
In my iOS app, I'm trying to set the text of a UILabel in another view. I do this by passing a NSNotification to the viewController when it should be updated. I know it is receiving the message correctly because I log the message, but it just isn't appearing in...

Updating width of uilabel when subview not

ios,uitableview,autolayout,uilabel
I have UILabel in a UITableViewCell whose neighboring subview is UIControlSwitch. When the UIControlSwitch is hidden, the UILabel's width is expected to grow. Below is my custom class implementation: - (void)setBounds:(CGRect)bounds { [super setBounds:bounds]; self.contentView.frame = self.bounds; } - (void)layoutSubviews { [super layoutSubviews]; [self.contentView updateConstraintsIfNeeded]; [self.contentView layoutIfNeeded]; self.numberLabel.preferredMaxLayoutWidth = CGRectGetWidth(self.numberLabel.frame);...

Is there a way to use a UIButton for text in a countdown timer?

ios,objective-c,timer,uibutton,uilabel
I'm a new in iOS Development and I am writing an app that has a countdown timer. I want the user to be able to tap on the time to set it so I used a UIButton as that seemed the easiest thing. I've seen questions on this site about...

How to blur UILabel text [closed]

ios,uilabel
I am trying to blur the text of UILabel without image blurring methods. I found many solutions but maximum are there for images. I tried shadow functionality of layer but that is not helpful.

How to change Custom Cell's UILabel Text?

ios,objective-c,uitableview,uiview,uilabel
I have a table view with a custom protoype cell and the cell has 3 different labels on it. How do I get access to these labels? I need to change their texts. I've searched around everywhere and haven't found something that helps me in this case. I have the...

Need to get NSRanges of multiple @ symbols and the text that follows them in UILabel's text

ios,objective-c,uilabel,nsattributedstring,nsrange
I have a UILabel that contains text like this: "Hi, my name is John Smith. Here is my twitter handle @johnsmith and I work for this company @somerandomcompany. Thanks for watching!" I need to find the ranges for all of the @ symbols and whatever text comes right after them...

swipe gesture strike through text [closed]

objective-c,xcode,uilabel,uiswipegesturerecognizer,swipe-gesture
I have been trying to come out a solution for using swipe gesture to the right and makes the text on a label.text with strike through effect, swipe again to remove the strike through and leaves the original text intact. Any example of codes as to how to do this?...

cell.textLabel.text not working after update to Xcode 6.2 using swift

ios,objective-c,xcode,swift,uilabel
I'm trying to set the value of the cell to a text value of a label that I place in the Main.storyboard, however after updating to Xcode 6.2 it start giving me an error that "UILabel doesn't have a member named text" before the update everything was working fine. this...

MVC communication, update label from model class in Swift

ios,swift,oop,model-view-controller,uilabel
I have a Model class, which has two methods: func callElements() -> String { if(count < elementsToShow.count - 1) { count += 1 var element = elementsToShow[count] println(element) return element } else { return "No more buttons" } } func changeLabel(){ var callV = ViewController().label var elementCall = callElements() println("111")...

Vertically center UILabel in parent UIView

ios,iphone,xcode,uiview,uilabel
How do I vertically (y-axis) center a UILabel inside its parent UIView without changing the horizontal position of the UILabel? The following is not it (it changes the x-axis): [self.label setCenter:CGPointMake(view.frame.size.width / 2, view.frame.size.height / 2)] Again, I am looking to center along the y-axis....

How to add background line in multiline label using NSAttributedString in ios objective-c

ios,objective-c,uilabel,cashapelayer
I want to add background line in multiline label using NSAttributedString in objective-c as shown in image below I used following code [yourView.layer setBorderWidth:5.0]; [yourView.layer setBorderColor:[[UIColor colorWithPatternImage:[UIImage imageNamed:@"DotedImage.png"]] CGColor]];///just add image name and create image with dashed or doted drawing and add here But it doesnt work perfectly and I...

How to format some text as bold within a UILabel? [duplicate]

ios,uilabel
This question already has an answer here: Any way to bold part of a NSString? 5 answers I have an iOS UILabel that needs some of the text to be normal and some of the text to be bold. The bold text is actually supposed to be a link...

How can I set a special character(right arrow) in UILabel?

xcode,uilabel
I am trying to set a text in UILabel, like this mylabel.text = @"▶ section1"; but, the right arrow character is translated to audio player icon inside UILabel. Is there a way to print right arrow character intactly as it is. Thank you....

TTTAttributedLabel sizetofit and sizeWithFont is different

ios,uilabel,sizetofit,sizewithfont,tttattributedlabel
I am using TTTAttributedLabel and I usually use sizetofit in my tableview cell. After that, I use sizeWithFont in my cell height calculation. I set TTTAttributedLabel like this. [self.attributedLabel setText:@"Test\n\n\n\n"]; CGSize contentSize = [self.attributedLabel.text sizeWithFont:self.attributedLabel.font constrainedToSize:CGSizeMake(CGRectGetWidth(self.attributedLabel.frame), 1000) lineBreakMode:NSLineBreakByWordWrapping]; [self.attributedLabel sizeToFit]; I notice that height is different. I got my output...

What's the equivalent of Android's “ClickableSpan” class in Swift/Objective-C?

ios,swift,uilabel,uitextview
So I'm trying to create a view where part of the entered text becomes a link to another UIView. I was searching a lot and found the ClickableSpan class that enabled to click on part of the text. It's like in Instagram where when a user types @username or #hashtag...

UILabel of custom UICollectionViewCell is nil

objective-c,uilabel,uicollectionviewcell
I try to make a custom UICollectionViewCell in storyboard. I have CustomCell.xib, CustomCell.h and CustomCell.m. In the .xib the Classname is linked and the identifier is set to "cell". The .xib contains 1 UIImage and 2 UILabels, all having IBOutlets to the .h class. In the ViewController where I'm using...

Swift: Problems printing out UILabel.text

ios,swift,uilabel
So I have this routine that sets different text uilabel.text values self.addressLabel.text = firstObject["ADDRESS"] as? String self.phoneLabel.text = firstObject["PhoneNums"] as? String self.latitude.text = firstObject["LAT"] as? String self.longitude.text = firstObject["LON"] as? String but when I try to print out println("\(latitude.text!)") It outputs: Label How can I make it so that the...

Reload UIViewController in “viewDidLoad”

ios,objective-c,uilabel,viewdidload
I change the value of 2 UILabels in my "viewDidLoad" method, but I need the view to refresh after that in order to display the values. As it currently stands, the UILabels display the value of the previously selected cell. I need to do the refresh right after I change...

How to pass label data to another label in the second view controller

objective-c,uilabel,pushviewcontroller
I've been searching for passing label data to another view controller, and found the following solution. However, it doesn't show the label text in another view controller. please help SecondViewController Header @interface SecondViewController : UIViewController { IBOutlet UILabel *copy; } @property (nonatomic, retain) NSString *data; In SecondViewController Implementation copy.autoresizingMask =...

Adding a UILabel to UIImage with renderInContext

ios,swift,uiimageview,uitextfield,uilabel
I've been trying for a long time to find the best way to add a UILabel with its background color to a UIImage. I need to add a exact replica of the label that is being shown on the screen to the image, if that makes sense to you. The...

iOS7 - Adjusting font size of multiline label to fit its frame

ios,fonts,uilabel,font-size
I need to fit a multiline attributed text in a UILabel's frame. Reading this thread How to adjust font size of label to fit the rectangle? I started from Niels' solution in order to work with attributed text. Here's the code: the 't' of 'prospect' is put in a new...

Displaying a string with multiple attributes in a label

ios,nsstring,uilabel,nsattributedstring
I need to display a string which will change every second. For example : View will refresh in 10 sec View will refresh in 09 sec View will refresh in 08 sec View will refresh in 07 sec .. View will refresh in 0 sec The above string needs to...

Get the vertical Size of a UILabel which has more than one line?

ios,swift,uilabel
I have a UILabel with more than one line: let serviceDescription: UILabel = UILabel() serviceDescription.text = "some very long text..." serviceDescription.numberOfLines = 0 serviceDescription.sizeToFit() self.contentView.addSubview(serviceDescription) Then I add some autolayout constraints: serviceDescription.snp_makeConstraints { (make) -> Void in make.top.equalTo(self.contentView_snp_top).offset(24) make.left.equalTo(self.contentView).offset(20) make.right.equalTo(self.contentView).offset(-20) } Now I want to compute the size this label...

UILabel Not Updating After Segue

ios,objective-c,xcode,uilabel
I segue to a UIViewController, and during its init method, 2 labels' text is supposed to be specified. However, that doesn't happen and the text never changes. All the connections are right, but they aren't displaying anything, and I can't figure out why. Below is the code that is supposed...

Vertically align text within a UILabel (xcode)

ios,iphone,xcode,swift,uilabel
Long time reader, first time poster. I have searched all over for a solution but I am yet to find an answer that works. Ok the problem: I have a UILabel which gets text dynamically assigned to it. If I resize the label to cover the entire view controller the...

lineBreakMode for multiline attributed string

ios,uilabel,nsattributedstring
I have a multiline label that will contain an attributed string. This is the code of the attributed string: NSString * titleString = @"Title"; NSString * informationString = self.myObject.content; NSString * allString = [NSString stringWithFormat:@"%@\n\n%@",titleString,informationString]; NSMutableAttributedString* attributedMessage = [[NSMutableAttributedString alloc]initWithString:allString]; NSMutableParagraphStyle* style=[[NSMutableParagraphStyle alloc]init]; style.alignment = NSTextAlignmentLeft; NSDictionary *attributesTitle =...

Object properties to UILabel

ios,objective-c,object,uilabel
I have some object with 18 properties (number of properties in that object is static and do not change over the time). Each property stores some information. I need to create a UILabels in cycle (for, foreach, etc.) and set current object.property to current label. How I can do that?

UILabel Swift/Storyboard returns nil

swift,uilabel
I created a navigation controller with a view controller inside, containing a label. This label should be changed, when the view controller is loaded on tapping a button. class ViewController: UIViewController { @IBOutlet weak var btnEmergency: UIButton! override func viewWillAppear(animated: Bool) { self.btnEmergency.backgroundColor = UIColor.redColor(); } override func viewDidLoad() {...

Swift : How to set IBOutlet from another controller?

ios,swift,uilabel
I want to hide my IBOutlet. However, setting text to empy string works perfectly fine, but when I acces directly my IBOutlet I keep getting error that "unexpectedly found nil while unwrapping optional value". I tried setting my IBOutlet to local varialble, but it gives error as well. I prepared...

Subview of UILabel disappears when the text was changed to Unicode string

ios,uilabel,subview,unicode-string
I am seeing a strange behavior of UILabel and its subview on iOS development. I want to have a overlay view on the UILabel and want to change only the text of the label. It works well when the text is digits or alphabets. However when I changed the text...

How do I handle long text labels on a universal storyboard?

ios,xcode,swift,uilabel
If the text of a label in a universal storyboard is too long to fit some resolutions, how do I accommodate it? Storyboard View iPhone 6 Emulator I'm not sure if there is a proper way to go about this according to the guidelines, but I would assume I would...

Custom cell to display multiline label using UITableViewAutomaticDimension

ios,uitableview,swift,autolayout,uilabel
Aim: To display a multiline label on a custom cell in a UITableView using autolayout and UITableViewAutomaticDimension. The cell should vary based on the text in each UILabel. What I have done: Used auto layout tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 100 label.numberOfLines = 0 (label is the new label I...

UILabel set framework doesn't work if the value is negative

ios,objective-c,uiscrollview,uilabel,frame
I have downloaded this project that show a small example regarding paging: Paging example project And I have added a label and by using the scrollViewDidScroll: delegate method that is called when any scrolling action takes place I call a method that resets the x position of the label aded...

Display json response in to UILabel

ios,json,uilabel
My json Response is like this .. { sentdetails = ( { coursename = "Course Two"; createddate = "05/12/2015 06:13 AM"; currentprice = "2.00"; "no_of_files" = 9; queryid = 36; querystatus = Open; submissionid = TSAb13d585e; testsaviornotes = None; title = Test; usernotes = rdgbv; } ); status = Sucess;}...

What to do if label is bigger than parent UIVIew?

ios,autolayout,uilabel
I have two multiline UILabels. The parent UIView only has a certain size (height) but the labels can contain a long string. What I want is that the first label is always shown (e.g. abbreviated with ... if it gets too long). If there is room the second label should...

Create a label with close button

ios,uilabel
I am looking for the best way to create a label with the close button in it. Do I need to place a button in the label or can i use the label as a button?

Fade the background color of UILabel ? (static display) [duplicate]

ios,objective-c,uiview,uilabel
This question already has an answer here: How to set gradient color to the background of UILabel in iPhone 1 answer I wanna fade the background color of UILabel. For example : from dark blue to light blue(just static display). How can I implement it?...

Swift - UILabel from URL

ios,swift,uilabel,nsurl
I wanted to know if it's possible to load the text in a label from a URL. I was going to try and use NSURL to pull in a .txt file stored online. Would anyone know how to implement this with swift? Thanks...

Pass a Class (UILabel) with its properties through a function Swift

ios,xcode,function,swift,uilabel
I am wondering if anyone knows how to (if possible) pass a UILabel through a function while being able to access and change its properties? Here's what I have: func plusMinusChange(minus: UILabel, plus: UILabel) { if (minus.hidden) { minus.hidden=false plus.hidden=true } else { minus.hidden=true plus.hidden=false } } And here's how...

iOS UILabel view updating has a delay even though console shows output immediately

iphone,swift,ios8,uilabel,synchronous
I'm trying to update a couple UILabels in my view, but I'm hitting a delay in the updating. I'm creating an NSURLSession, which I don't know if that's what's causing the problem, but I'm able to update other UILabels outside this chunk of code without any delay. When this code...

Get string of first line in a UILabel

ios,objective-c,uilabel
I have some text in a UILabel. I want to get the text of the first label in a string variable. For example: label.text = @"You make an object by creating an instance of a particular class. You do this by allocating the object and initializing it with acceptable default...

Change text of label in ios camera overlay UIPickercontroller

ios,objective-c,xcode,uilabel,uipickerviewcontroller
I'm trying to change though a timer in a different method the text of a label I created programmatically in a UIView overlay that goes on a UIImagePickerviewController, but of course when I try to change the text in this way labelname.text = @"TEST"; I get the error "use of...

What's the difference between var label: UILabel! and var label = UILabel( )?

ios,swift,uilabel
I notice when I'm writing in Swift, if I declare a label in the ViewController as either var label: UILabel! or var label = UILabel(), and then initialize them in the viewDidLoad method, they both seem to, functionally, work identically. So what is the difference between these two? On a...

How to get monospaced numbers in UILabel on iOS 9

ios,uilabel,uifont,monospace,ios9
In this years WWDC there was a session about the new system font SanFrancisco in iOS 9 which uses proportional number rendering instead of monospaced numbers per default when linked against the iOS 9 SDK. There is a convenient initializer on NSFont called NSFont.monospacedDigitsSystemFontOfSize(mySize weight:) that can be used to...

shadow in UILabel

ios,objective-c,uilabel
I tried subclassing UILabel with the following code.. but unable to get a look similar to - (void) drawRect:(CGRect)rect { CGSize myShadowOffset = CGSizeMake(4, -4); CGFloat myColorValues[] = {0, 0, 0, .8}; CGContextRef myContext = UIGraphicsGetCurrentContext(); CGContextSaveGState(myContext); CGColorSpaceRef myColorSpace = CGColorSpaceCreateDeviceRGB(); CGColorRef myColor = CGColorCreate(myColorSpace, myColorValues); CGContextSetShadowWithColor (myContext, myShadowOffset, 5,...

Change first line color of UILabel

ios,objective-c,uilabel,nsattributedstring
I'm trying to change a UILabels first line's color. It's not working for some reason. Here is my code: NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithAttributedString: label.attributedText]; [text addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:[label.text rangeOfString:@"\n"];]; [label setAttributedText: text]; I don't see any changes in the first line....

UILabel cutting off text

objective-c,xcode,uilabel
I have a bit of a strange problem. I have a UITableView controller. Inside the UITableViewCells are four profile images for the user and below each picture is a UILabel to display the name. All the labels are the same size and all the constraints are equally set up. The...

Multiple UILabel not displaying with UIView loaded from nib

ios,objective-c,uiview,uilabel
I am trying to load a UIView from nib and place it as the 'header' for a UICollectionView using the following code inside the view controller's viewDidLoad: self.collectionView.contentInset = UIEdgeInsetsMake(220, 0, 0, 0); self.overView = (OverviewView *)[[[NSBundle mainBundle] loadNibNamed:@"OverviewNib" owner:self options:nil] objectAtIndex:0]; [self.overView setFrame:CGRectMake(10, -210, self.view.frame.size.width - 20, 200)]; [self.collectionView...

iOS: How to Detect subview position around view

ios,objective-c,uiview,uilabel,uitouch
I have a Label named "Lable_Match" (in self.view) and a UIView(in self.view). In that View there are 1000+ labels. and view is move using touch move method. and When user move View and he touch end that time check view subview lable is on the "Lable_Match" if any one lable...

How to wrap a text on a UIButton in swift

ios,swift,uibutton,uilabel
I try to wrap a text on a button as follow: nextButton=UIButton(frame: CGRectMake(buttonHWidth, textHeigth, buttonHWidth, buttonHeigth)); nextButton.backgroundColor = UIColor.lightGrayColor() nextButton.setTitle("", forState: UIControlState.Normal) nextButton.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside) nextButton.tag = 22; label_nextButton = UILabel(frame: CGRectMake(buttonHWidth, textHeigth, buttonHWidth, buttonHeigth)); label_nextButton.textAlignment = NSTextAlignment.Center;...

Clickable username and hashtag in UILabel (Not UIWebView!)

ios,objective-c,swift,uilabel,clickable
The idea is for example there is a UILabel (like in Instagram) "User1 started following User2" I want that when we click either on chunk of text 'User1' or 'User2' it does some action(Not opening like usual link in UIWebView) Tried TTTAttributedLabel , didn't find anything which will fit me...

Ambiguous layout warnings for UILabels in UITableViewCell

ios,uitableview,autolayout,uilabel
I have two UILabel views next to each other in an UITableViewCell. The left one has one line, the right one can have multiple lines and uses whatever horizontal space that is left. Both labels have the same distance from the top of the cell. The height of the cell...

UILabel word wrapping

ios,objective-c,uilabel,wrap,word
I have a UILabel set up to have a maximum of 2 lines, that word-wraps when there is too much content. I have a problem where when there is only a single word left over, it doesn't bother to wrap and truncates the text. how can I get it to...

Swift: How can you rotate text for UIButton and UILabel?

ios,swift,uibutton,uilabel
How can you rotate text for UIButton and UILabel? 90 degrees, 180 degrees Note: Before you mark this as a duplicate, I am intentionally modelling my question as a Swift version of this one: Objective C: How can you rotate text for UIButton and UILabel?...

AutoLayout constraints to UITableViewCell contentView not respected

ios,uitableview,autolayout,uilabel
I'm trying to create dynamically resizing table view cells. I accomplished the resizing by using this answer, which is very detailed and helpful. However, the maximum width for the label is not being calculated correctly inheightForRowAtIndexPath. My cell currently only has one label in itscontentView, with constraints set to pin...

Why is boundingRectWithSize wrong when using UIFont preferredFontForTextStyle?

ios8,nsstring,uilabel,uifont
I have found that a call to boundingRectWithSize is extremely incorrect, missing an entire additional line, when called with NSFontAttributeName : [UIFont preferredFontForTextStyle:UIFontTextStyleBody]. However, using the font [UIFont fontWithName:@"Helvetica Neue" size:17.f], it is just fine. Here is test code showing the bug: - (void)viewDidLoad { [super viewDidLoad]; NSString *measureText =...

How to insert a Cursor into UILable's Text

swift,ios8,cursor,uitextfield,uilabel
i need to insert a cursor in the text .. i don't want a textField (user don't type in it) .. i just need the cursor itself . so i can put it manually wherever i want .. like button's title . or UILabel .. I tried to just type...

Which UILabel method is invoked when I set text, and it resizes itself to fit?

ios,storyboard,uilabel,nslayoutconstraint
I have an UILabel, created in Universal storyboard, and I have mentioned all required constraints for its position OTHER THAN WIDTH. So it resizes itself as per the text set. Fantastic! Exactly what I want. Problem starts here : It has background color as green color, but that color is...

Can't verify if label text is blank

ios,swift,uilabel
I am trying to do something fairly simple, but I can't get it figured out. I have a label that is populated based on an alert controller action. I am trying to create an alert that will pop up if the user did not select an option to populate the...

Center a UIImageView and a UILabel together in a UIView

ios,uiview,uiimageview,uibutton,uilabel
If I declare a UILabel and a UIImageView of different sizes can I then center them in a UIView with 10.0points between the two horizontally? Thanks!...

Wrap Text in UITableView Custom Cell When It Reaches End of Screen (Swift)

ios,uitableview,swift,uilabel
I have a table that loads data from a database but the problem is if the text being loaded is too long, it goes off the screen. I'm trying to find a way for the text to go onto the next line and have the cell resize automatically to fit...

Update a label when closing Notification Center

ios,objective-c,integer,uilabel
I think I need some help. In my App, I do have a UILabel, whose text is coming from an "integer". Whenever the View loads, it gets the actual in NSUserDefaults stored value for the integer: NSUserDefaults *defaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.sam.Widget"]; counter = [defaults integerForKey:@"MyNumberKey"]; numberLabel.text = [NSString stringWithFormat:@"%d",...

UILabel does not wrap on initial load within TableViewCell

ios,swift,uilabel,tableviewcell
I am creating a chat based app, which uses a UITableView to hold all the messages within a conversation. To create a chat bubble, I have a wrapper view (wrapView) which is constrained to the top, bottom, right, and left of the TableViewCell. As a subview I have a UILabel...

Detect number of touches

ios,uilabel,uigesturerecognizer,touchesbegan
I have a problem, In my app I have a Label and when I touch on it a method is fired, I implemented with -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event, the problem is that when I touch, the method is fired (everything is working) but I want when I touch once again...

Auto size UILabel text

ios,objective-c,uilabel
I have a UILabel with multi lines. I'm trying to get the text to auto size, and fit on the line it's in. So instead of: longe st The text size should become smaller so that it can fit on the same line: longest Note: I only need it for...

How to know the width of last line of label?

ios,iphone,swift,uilabel
In my app I have a label which text came from the server so I don't Know its width, and at the end of this label directly there should be an UIImage. My problem is: I don't know how to position the image because of the non static width of...

How to align custom UINavigationBar title (UILabel )in middle (iOS)

ios,objective-c,uiview,uilabel,uinavigationbar
I am using following code to align 2 strings in UINavigationBar centre . for ex: <Back John Kelly Maria 23/F I need these kind of middle aligned text in UINavigationbar but what jam now getting is all the text aligned in right side of UINavigationBar . something like this <Back...

It is possible to continuously update the UILabel text as user enter value in UITextField in iOS

ios,objective-c,swift,uitextfield,uilabel
In my application i have one UILabel and UITextField. Initially UILabel text in nil. As soon as user enter some text in UITextField my UILabel text also Update. Let say When user enter A in UITextField my UILabel immediately show A, B in UITextField my UILabel show B and so...

UIView Animation not shown after segue

swift,uiview,uicollectionview,uilabel,uiviewanimation
I have 2 View Controllers. The first one is a Collection View Controller, the second a plain View Controller. When clicking a cell in the Collection View Controller, the second View Controller appears. When the view starts to load in the 2nd view controller, I want to show a UILabel...

Change date in UILabel when click next and previous UIButton

ios,objective-c,uilabel,nsdate,updates
Set a date in UILabel. The click on "next" and "previous" buttons should change date inside this label. I'm trying this code but next button click and show date next day date for e.g 01/05/2015 and previous button click and set date 29/05/2015 and next button click not display 02/05/2015...

How can I animate the size of UILabel or UITextField text?

ios,objective-c,uilabel,core-animation
I have a UITextfield in a UIView that contains some default text. I want to animate the scaling of this textField (along with the parent UIView) %300, and later back down to 100%. How do I do this? It seems everything I've found involves a hacky image capture and a...

UILabel not wrapping reliably

ios,swift,uilabel,nslayoutconstraint
It seems impossible to get the UILabel to adhere to the constraints in the way that I want it to consistently. The leading and trailing space constraints seem in effect but the label is just truncating the lines instead of expanding to new lines. I do have the numberOfLines of...

How to update UI with WatchKit?

ios,uibutton,uilabel,watchkit
I created a sample watchkit app and I dragged a UIButton and UILabel into the storyboard app scene. I was able to hook up the UIButton to the interface controller and got it to update the UILabel. But the label.text was not reflected in the simulator. Nothing changes. Do I...

fatal error when prepared to segue to view controller

xcode,swift,uilabel,segue
I'm currently getting a fatal error unexpectedly found nil while unwrapping an optional value at destViewController.titleLabel.text = "Testing Segue". How do I fixed it since it getting me a error when it segue to SecondViewController? How do I avoid getting nil at titleLabel.text? class ViewController: UIViewController { @IBAction func action(sender:...

Animation of setAlpha for UILabel not working

ios,objective-c,animation,uilabel,alpha
I have some UILabels on a view that I want to fade when the someone is holding down on the view. I am trying to perform the fade by changing the alpha value of the text from 1.0 to 0.5 and then back again when the touch is released. Here...

Set different font styles for WKInterfaceLabel with multiple lines

swift,uilabel,watchkit,wkinterfacelabel
I'm developing an apple watch app - it consists of two tables that contain labels. These labels have two lines of text, I want the second line of text to have a different font style to the top line How can I do this in swift? Thanks everyone...

Adjusting UILabel size and text position after calling sizeToFit

ios,objective-c,uilabel
Current result: I'm able to adjust the size of the label by calling sizeToFit, which does a decent job at framing the text -- however, even with NSTextAlignmentCenter, the text is not exactly centered horizontally or vertically. To adjust the text positioning within the label, I've overridden drawTextInRect: to adjust...

How to change UILabel text color on Custom UITable cell?

objective-c,uilabel,tableviewcell,swrevealviewcontroller,viewwithtag
I've created a table view controller on storyboard. I want to change UILabel text color to green when i clicked on the selected row. I'm trying something like this, but it's not working: - (void)viewDidLoad { [super viewDidLoad]; menuItems = @[@"home", @"stamp", @"scanner", @"settings"]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath...

How to animate an UILabel from small to its original size?

ios,objective-c,uilabel,uianimation
Actually i am using RESlider in my app. In the menu table view there is a profile image and aside to it there is a notification label. Now i want is that when the user presses the hamburger menu the notification label(orange label with 999 number) should animate from a...

Assigning Text to Labels Dynamically

ios,objective-c,uilabel
I am having a user enter in text through text field and then display it in a label in a separate ViewController. Basically what I need to happen is 1 - Have the user enter in text 2 - The second ViewController creates and assigns the the text to a...

How to redefine “word” in NSLineBreakByWordWrapping

ios,objective-c,uilabel
Text: 【233 24444 2223】【233 24444 2223】【233 24444 2223】【233 24444 2223] I want to break the text in a UILabel From: 【233 24444 2223】【233 24444 2223】【233 24444 2223】【233 24444 2223】 To: 【233 24444 2223】【233 24444 2223] 【233 24444 2223】【233 24444 2223】 In another word,I want to tell the UIlabel that the...

Implement some insets in HTMLLabel but “drawTextinRect” get never called

ios,objective-c,uilabel,uiedgeinsets
I´m using HTMLLabel (https://github.com/nicklockwood/HTMLLabel) and i would like to implement some insets. So i wrote in the HTMLLabel.m file: - (void)drawTextInRect:(CGRect)rect { UIEdgeInsets insets = {0, 5, 0, 5}; [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)]; } But the method never get called, any ideas why? Thanks for your help!...

Adjusting font size for UILabel according to device screen iPhone4/5 and iPhone6/Plus

ios,objective-c,iphone,fonts,uilabel
I am using Autoresizing for UILabel on the xib. And when i launch app on iPhone4/5 UILabel font looks perfect but for iPhone6/Plus font looks very small. I referred so many link including Adjusting font size according to device screen and Category for UILabel Also the adjustsFontSizeToFitWidth is not working...

UILabel text updation

ios,ios7,uilabel
I have aUILabel which I want to update. If I will login with a user name then the UILabel will be updated with that user name,which it is doing correctly and storing the value. Now I want whenever i will logout then the UILabel text should return the previous value...

Changing UILabel text has delay, but why?

ios,swift,uilabel
in my app I want to set the text of an UILabel. The text comes from a JSON-object. I add my UILabel to my storyboard, set the IBOutlet and call my async-method to get my JSON-object. In the response-method I set the text of the UILabel. But the text change...

How can I enforce an UILabel to be wider than it should be, by 5 points?

ios,objective-c,uilabel,uistoryboard,nslayoutconstraint
I have an UILabel, it has background color as green. But It wraps the text very closely. I need the green background to be little wider than the text, approx 5 points. How can I achieve this? Details Label is created in storyboard and has horizontal spacing constraints. You can...

bug with LineBreakMode

ios,objective-c,uilabel,nsparagraphstyle
Can you explain me why NSLineBreakByWordWrapping sometimes not working? It's tableView NSMutableParagraphStyle *paragrahStyle = [[NSMutableParagraphStyle alloc] init]; [paragrahStyle setLineSpacing:4]; paragrahStyle.lineBreakMode = NSLineBreakByWordWrapping; //Char [[cell titleLabel] setAttributedText:[[NSAttributedString alloc] initWithString:((Post *)posts[indexPath.section])->title attributes:@{NSParagraphStyleAttributeName : paragrahStyle, NSFontAttributeName : [UIFont fontWithName:@"Roboto-Condensed" size:24.0f]}]]; ...

iOS swift multi-line UILabel in a view

ios,uiview,autolayout,uilabel,multiline
I would like to accomplish what is seen in the image below in Interface Builder. Basically two labels - one multi-line and one note - inside a view and the view centered horizontally on the page. So to be clear, I cannot put a width constraint on the view or...

Standard text colour by subclassing UILabel for use on a storyboard - (IBOutlet)

ios,objective-c,uilabel,subclass
I'm looking to create a standard look and feel within my App, where some UILabel have a specific textColor. I have several UILabel on my UIViewController, and in the viewDidLoad method I'm calling a function that sets the textColor property: [[CHToolKit sharedToolkit] uiLabelAppearanceFeatured:[self IBOLabelStepsRemaining]]; CHToolkit is a singleton I created...

UILabel returns “nil”?

swift,uibutton,uilabel,nil,ibaction
I am having trouble with my UIButton. For Example, when I click the the UIButton Number3 and hit the checkButton on the ViewController the result in the currentCountLabel is Optional(3). It does this for every number after I click the checkButton. If I then click the button again, the currentCountLabel...

Indent second line of UILabel

ios,objective-c,uilabel
So I have a UILabel that may or may not go to a second line, depending if it is on iPhone or iPad. What I would like to accomplish is to have it indent on the second line to line up correctly, if needed. On iPad it will almost never...

How do I toggle hidden of a label while a button is pressed?

ios,uibutton,uikit,uilabel
I am trying to figure out how to only display a label while a button is pressed in OS. I know how to operate the touch events but I am not sure how to incorporate the UILongPressGestureRecognizer into this.

iOS gradient effect over UILabel

ios,objective-c,iphone,uilabel
I want to add gradient effect on a UILabel so it look like: Please note the gradient effect on left and right corner.I've no clue how to do that.any help or suggestion would be appreciated. Edit: - I tried with this code- UIColor *endColor = [UIColor colorWithRed:20/255.0 green:157/255.0 blue:189/255.0 alpha:1.0];...

Center multiple UILabels on a line

ios,swift,view,uilabel,center
I want to horizontally center multiple UILabels - as a group - on a line in Interface Builder. One the straight view controller i could not figure out how to do this. I read comments about place the UILabels in a View and then centering the view in the view...

Change paragraph height (not line spacing) in a UILabel

ios,uilabel,nsattributedstring
Is it possible to limit the distance between paragraphs that were created using \n\n smaller in UILabels using attributed strings? So for example, I would like this: To look like this: Would this involve replace \n\n with something else? Or is there a much simpler solution using NSAttributedString?...

In a UILabel, is it possible to force a line NOT to break at slash?

ios,uilabel,core-text,hyphenation
Example: My text is @"This is a great UI/UX feature". A better example: @"5/17 of this quantity". Is it possible to force the line NOT to break at the / (the slash)? I'm looking for a general way of doing, since I have others sentences with slashes....

How can I centre both vertically and horizontally in a UILabel after resizing the text to fit width (1 line label)?

ios,objective-c,uitableview,uilabel
This is really frustrating me. I notice there are a lot of questions regarding this but I can't seem to get any of it to work. I have tried UILabel. I have tried UITextField (which works to a certain extent but some of the text doesn't get resized all the...