uilabel

How to write a Custom UILabel Class

有些话、适合烂在心里 提交于 2019-12-12 17:15:11
问题 In my project there is a huge number of UILabels available for each screen that's why I have created one separate class for UILabel and I want to set all label properties in that class. But label properties and label also not adding in my MainViewController . My code: CustomLabel: #import "CustomLabel.h" @implementation CustomLabel - (id) init { self = [super init]; if(self){ [self setupUI]; } return self; } - (void)setupUI { [self setBackgroundColor:[UIColor redColor]]; [self setTextColor:

How to Subclass UI elements like UILabel, UIButton

依然范特西╮ 提交于 2019-12-12 16:12:51
问题 I am subclassing an UILabel in a CustomLabel class . I have problems when I try to use a simple UILabel and I will like to subclass other elements in a future. I have read that I can create a category of UILabel . Which of this things is better? category or subclass? Here is my code trying to subclass. It fails in setFont method. @interface WPCustomLabel : UILabel @property (strong, nonatomic) UIColor *color; @property (strong, nonatomic) UIFont *font; @end #import "WPCustomLabel.h"

Updating label text (dynamically) while executing another method

陌路散爱 提交于 2019-12-12 14:33:43
问题 I am an iOS developer currently developing an iphone application. I have a simple question regarding updating the contents of a ViewController and I would greatly appreciate it if I can get someone’s feedback who is aware of this issue or have a suggested solution. I’m writing a method that constantly updates the text of a label (and other components such as the background colour of a UIImage “box1” and “box2” ). The issue : update to the text of the label (along with other changes) only

UILabel animating improperly

↘锁芯ラ 提交于 2019-12-12 14:15:16
问题 For some reason, UILabel's text wants to set its alignment without animation, and I cannot figure out how to get the text to animate along with the rest of the label. I have the following code right now: UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(40,200,100,50)]; [label setText:@"Label Name"]; [label setBackgroundColor:[UIColor blueColor]]; [label setFont:[UIFont systemFontOfSize:17.0]]; [label setTextColor:[UIColor blackColor]]; [label setTextAlignment:NSTextAlignmentCenter];

UILabel text not changing, however xx.title is working

浪子不回头ぞ 提交于 2019-12-12 12:29:19
问题 I have two view controller. In first view controller I have list of names. When I click on that, I want the same name to be displayed in second view controller. I have below code. -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // PropDetailViewController is second view controller PropDetailViewController *prop = [self.storyboard instantiateViewControllerWithIdentifier:@"prop"]; ListOfProperty *propList = [propListFinal objectAtIndex:indexPath.row

How to angle a uilabel in ios [duplicate]

时光总嘲笑我的痴心妄想 提交于 2019-12-12 11:33:58
问题 This question already has answers here : How can you rotate text for UIButton and UILabel in Objective-C? (7 answers) Closed 6 years ago . i'm creating an iphone app.in that application i want to angle the label according to the attached screen shot. (see the $ 120 lable) The red color image is in the background and i want to angle the uilabel top of it I have used the transform method to rotate . But it does not properly angle it. label shrinks testLabel.transform =

Text padding on UILabel

拥有回忆 提交于 2019-12-12 10:00:20
问题 Here, I am trying to have a label with some padding (left, right, top and bottom) around the text. This issue has related post on SOF and after reading a few of them, I tried using a solution proposed here: This is the code for my subclassing UILabel: import UIKit class LuxLabel: UILabel { //let padding: UIEdgeInsets var padding: UIEdgeInsets = UIEdgeInsets.zero { didSet { self.invalidateIntrinsicContentSize() } } // Create a new PaddingLabel instance programamtically with the desired insets

In iOS - How do I fit a UILabel to its text, without changing its position?

a 夏天 提交于 2019-12-12 09:36:19
问题 I'm calling sizeToFit on a UILabel which has right aligned text in it. It shrinks the height and width of the UILabel and fits the text to the top left of the UILabel . Now...the position of the UILabel is incorrect. How can I make the UILabel stay in its original position (right aligned) or move it so it'll appear at its original position? Once again - the problem is that the sizeToFit method is shrinking the width from the right side of the UILabel . It is treating the UILabel text as left

Images inside of UILabel

对着背影说爱祢 提交于 2019-12-12 09:08:11
问题 I'm trying to find the best way to display images inside of UILabels (in fact, I wouldn't mind switching to something other than UILabel if it supports images with no hassle) The scenario is: I have a table view with hundreds of cells and UILabel being the main component of each cell The text I assign to each cell contains sequences of characters that need to be parsed out and represented as an image In simpler words, imagine a TableView of an instant messenger that parses replaces all ":)",

How to fix the Gradient on text when using an image in swift, as the gradient restarts

夙愿已清 提交于 2019-12-12 08:48:44
问题 I'm trying to create a gradient on text, I have used UIGraphics to use a gradient image to create this. The problem I'm having is that the gradient is restarting. Does anyone know how I can scale the gradient to stretch to the text? The text is on a wireframe and will be altered a couple of times. Sometimes it will be perfect but other times it is not. The gradient should go yellow to blue but it restarts see photo below: import UIKit func colourTextWithGrad(label: UILabel) {