uilabel

Adjoining “f” and “l” characters

二次信任 提交于 2019-12-08 13:14:54
问题 For some reason, when I display the word "Butterfly" (or anything else with an "fl"), the "f" and the "l" connect at the top (see image below). The font is Century Gothic Bold. This is the code I use to setup the UILabel. The string for the label is retrieved from a plist: UILabel *label = [[UILabel alloc] init]; label.text = [self.flashcardDelegate.alphabetArr objectAtIndex:index]; label.textColor = [UIColor colorWithRed:.733 green:0 blue:.03137 alpha:1]; label.backgroundColor = [UIColor

How can i click button and change label text in tablewviewcell

丶灬走出姿态 提交于 2019-12-08 13:09:05
问题 I want to change label text when i was click button in every TableViewCell I mean have 2(-,+) button and 1 label, When I click on the button, the label will increase or decrease. I have no idea How to do it? 回答1: you need to maintain a quantityArray to store current quantity of every index var quantityArray:[Int] = [] //initialize quantity array then add initial quantity values to quantityArray For example : If your list array count 10 and initial quantity of all item will be one means add

Check how close UILabels are to each other

旧街凉风 提交于 2019-12-08 13:01:49
问题 I am trying to make a game which has a jumbled up algebra equation. I have assigned an outlet to each component of the equation. For example, if the equation was: x2 + y = 2(a+b) Then x2 (which is x squared), +, y, = and 2(a+b) would all be its own outlet. But the equation is going to be jumbled up and I want the user to move the label outlets to the correct order. I have enabled touchesMoved, but my problem lies in checking if the equation is in the correct order. I would wrap the code into

numberOfLines in UITextview?

可紊 提交于 2019-12-08 12:57:46
问题 UIlabel has numberOfLines property. It says my string has 2 lines. But when I use UItextview , I want to split the number of lines based on length of text in UITextview. How can I do it? UIlabel automatically splits, but UITextview does not do it. 回答1: The lines should be separated by "\r" Here's an example: lblNeedSubscription = [[UILabel alloc] initWithFrame:frame]; [lblNeedSubscription setNumberOfLines:0]; // allows as many lines as needed [lblNeedSubscription setText:@"To access content

Changing Label Text & Colour Depending On Current Time

£可爱£侵袭症+ 提交于 2019-12-08 12:24:12
问题 I am trying to change the label that you see in my screenshot that has a green background and says We Are Open. I would like the bottom label to turn RED and say "Sorry we are closed" whenever the listed opening times have passed and then go back to GREEN and say "We Are Open" at the correct opening times. I've managed to import date and time successfully into the top label but I'm not sure how do the bottom label. Here is the code: import UIKit import Firebase import FirebaseInstanceID

Add Read More/Read Less to the end of UILabel SWIFT

隐身守侯 提交于 2019-12-08 11:48:23
问题 Hi i need a UILabel with Read More and Read less But didn't find any good answer except this one But the problem is, I don't know what this answer is doing. As i have tried this, but getting errors, also IN THIS ANSWER what is "@IBOutlet weak var lblHeight: NSLayoutConstraint!" My code import UIKit class ExpandedLabelViewController: UIViewController { @IBOutlet weak var myLabel: UILabel! @IBOutlet weak var lblHeight: NSLayoutConstraint! @IBOutlet weak var btn: UIButton! var isLabelAtMaxHeight

UILabel does not show all my text and it also doesn't show that there is more (…)

邮差的信 提交于 2019-12-08 10:32:09
问题 I am determining the height of my cells dynamically, to fit all my text. I also set the number of lines to 0. It works most of the time but sometimes I get things like this: There is more text than is shown, and even if I log the label text, it shows more that what is being displayed. The black frame is used to show that the frame is big enough to hold the text but for some reason the label refuses to show all my text. Has anyone experienced anything like this? Can anyone help me solve this?

How to create NSMutableArray of UILabels?

爷,独闯天下 提交于 2019-12-08 10:00:37
问题 I have a problem here. I'm creating UILabels dynamically to be displayed into a UIView. Here is the code: for (flower in flowerList) { // Create the Qty label CGRect rectQty = CGRectMake(x , y, 25, labelHeight); UILabel *flowerQuantityLabel = [[UILabel alloc] initWithFrame:rectQty]; NSString *fQty = [[NSString alloc] initWithFormat:@"%d", flower.flowerQty]; [flowerQuantityLabel setText:fQty]; // Loading refrence into a array // here is the problem [flowersQtyLabels addObject

iOS auto adjust label height

拥有回忆 提交于 2019-12-08 09:07:08
问题 I'm using the following code to auto adjust the height of a label in a UITableView. It works the majority of the time, but certain times text is cut off. Is there something wrong with my code, or anything else I need to add? UILabel *textLabel = ((UILabel *)[cell viewWithTag:3]); textLabel.text = text; CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX); CGSize expectedLabelSize = [text sizeWithFont:textLabel.font constrainedToSize:maximumLabelSize lineBreakMode:textLabel.lineBreakMode]; /

UILabel and getting the size after autofit

不想你离开。 提交于 2019-12-08 08:15:37
问题 I have an instance of UILabel with a default font size of 28 and minimum font size of 16 . I allow the font to auto-adjust to fit subject to this minimum and with one line only. Suppose I have some text in the UILabel that has been automatically adjusted to fit. How do I get the new font size, or to be more precise the scale factor applied to the label's content? [NB. The font property does not change under autofit.] 回答1: I'm afraid that this calculation is done at draw time and not