uilabel

Issues with custom font in iOS

烈酒焚心 提交于 2020-01-21 06:04:30
问题 I followed the steps outlined in various locations using the UIAppFonts property list key. I'm using the Aller Light font. I've added it as a resource, added the font name correctly in the info property list, and am now attempting to use it, however every attempt to do so results in the default font being displayed. So far I've tried: [leader setFont:[UIFont fontWithName:@"Aller Light" size:20.0]]; [leader setFont:[UIFont fontWithName:@"AllerLight" size:20.0]]; [leader setFont:[UIFont

Show more button next to end of text Swift

会有一股神秘感。 提交于 2020-01-21 05:00:08
问题 I want to show more button at the end of the text or below if there isn't enough space. I don't understand how Apple developers did this? Please answer in swift. After clicking on more button i want to show all the text. change the button to less. Thanks in advance. 回答1: Here's a great CocoaPod for the functionality you're looking for. https://github.com/ilyapuchka/ReadMoreTextView This will allow you to set a maximum number of lines and customise the text append to the end of the trimmed

iPhone - Adjust UILabel width according to the text

喜你入骨 提交于 2020-01-20 17:02:26
问题 How can I adjust the label Width according to the text? If text length is small I want the label width small...If text length is small I want the label width according to that text length. Is it possible? Actually I have Two UIlabels. I need to place these two nearby. But if the first label's text is too small there will be a big gap. I want to remove this gap. 回答1: //use this for custom font CGFloat width = [label.text sizeWithFont:[UIFont fontWithName:@"ChaparralPro-Bold" size:40 ]].width;

Putting text input from one view to another

£可爱£侵袭症+ 提交于 2020-01-17 08:20:12
问题 I have tried so many tutorials that I am wondering why I am not getting such a simple problem. I have a view controller called SetBudgetViewController. I have a text field in this view that I have connected as an outlet called *amountToSpend. I have another view used elsewhere in the app that has a label called *amountSet. How do I make the numbers entered into the first text field be displayed in the label in the other view? Thank you all so much (this is driving me mad)! 回答1: First, declare

Autolayout causing UILabel to resize with unwanted padding

只谈情不闲聊 提交于 2020-01-17 03:09:33
问题 I have a customized UITableViewCell that has an image on the left and two UILabels on the right. The top edge of the first label is horizontally aligned with the top of the image, and the second label has its bottom edge aligned with the bottom of the image. The second label displays a larger content and I'm hoping that it could resize vertically to show more content but it should not interfere with the top label(for which I've set a vertical spacing constraint between the top label and the

iOS controlling a slider value and text label value with a stepper

谁说我不能喝 提交于 2020-01-16 18:10:09
问题 I already have a slider that controls the output of a text label. -(IBAction)mySlider:(UISlider *)sender { _myTextLabel.text = [NSString stringWithFormat:@"%i", (int) sender.value]; } However, I also want a stepper to be able to changer the slider's position. So, if the slider has been set to 50, and the text label says 50, I want the stepper to increment to 51, 52, 53, etc. Does anyone know the code to do this? Thanks! 回答1: You will need to keep an reference for the UISlider . Make a handler

IOS/Autolayout: Make UILabel go to more than one line with Autolayout

…衆ロ難τιáo~ 提交于 2020-01-16 10:37:06
问题 I need to get a UILabel to go to more than one line if text requires with autolayout. In code and also in storyboard for good measure I have set numberOfLines to 0 and wordwrapping on and I've also called sizeToFit . The full amount of text will display on multiple lines if I set the height constraint for the label to a large enough value such = 200. But with short text, it does not contract, leaving a lot of white space. But if I set the height constraint to a lower value such as >=21 then

vertically center UILabel between two other lables

有些话、适合烂在心里 提交于 2020-01-16 02:51:23
问题 I have 3 UILabels drawn in storyboard positioned on top of each other. Static UI Label 1 Dynamic UI Label 2 Static UI Label 3 Labels 1 and 3 are static and never change. Label 2 is dynamic and is always one sentence long, but could be a short or long sentence that wraps. I want Label 2 to be perfectly vertically centered between label 1 and label 3 based on how much text is there. Any ideas how to do this? Greatly appreciated! 回答1: If you're using auto layout (which is on by default), then

Autolayout: UILabel not resizing properly with long text

那年仲夏 提交于 2020-01-15 05:40:49
问题 I have a UITableViewCell with two UILabel s: title and description. I am having problems with the title label. Basically, what I want is to increase its height if the text is bigger than the available space and prevent the "...". This is how it looks, you can see the constraints of the title label on the right. As you can see, the title label successfully increase its height but the text still in one line. The font used in "Text Styles - Callout". Any suggestions? Edit 1 : I already set

Way to draw NSString on a curved path?

喜夏-厌秋 提交于 2020-01-14 09:04:22
问题 I have been looking for any example code for drawing a UILabel (or just an NSString or something) on a curved path, but have come up empty handed. Does anyone know whether it's possible to draw text on a curved path, like a circle or something, without using separate pieces of graphics for every single letter? 回答1: Split the String into letters and then so something like this: How do I draw an NSString at an angle? increasing the angle and changing the position after every letter. 来源: https:/