uilabel

iPhone - UILabel containing text with multiple fonts at the same time

谁说我不能喝 提交于 2019-12-17 00:59:11
问题 I am looking for a way to use a UILabel (or something similar) to display something like this: Tom: Some message. It is like how it's done in for example the Facebook app to display the "what's on your mind?" messages. Does anyone have any suggestions how to approach this? 回答1: Use two UILabel IBOutlets, each with a different format (font/color/etc), as you desire.. Move the second one over the first based on where the first one's text ends. You can get that via sizeWithFont:forWidth

Underline text in UIlabel

北城余情 提交于 2019-12-17 00:48:03
问题 How can I underline a text that could be multiple lines of string? I find some people suggest UIWebView, but it is obviously too heavy a class for just text rendering. My thoughts was to figure out the start point and length of each string in each line. And draw a line under it accordingly. I meet problems at how to figure out the length and start point for the string. I tried to use -[UILabel textRectForBounds:limitedToNumberOfLines:] , this should be the drawing bounding rect for the text

Adding space/padding to a UILabel

你说的曾经没有我的故事 提交于 2019-12-16 22:37:07
问题 I have a UILabel where I want to add space in the top and in the bottom. With minimun height in constrainst I've modified it to: EDIT: To do this I've used: override func drawTextInRect(rect: CGRect) { var insets: UIEdgeInsets = UIEdgeInsets(top: 0.0, left: 10.0, bottom: 0.0, right: 10.0) super.drawTextInRect(UIEdgeInsetsInsetRect(rect, insets)) } But I've to find a different method because if I write more than two lines the problem is the same: 回答1: If you want to stick with UILabel, without

Set UITableViewCell's height depending on the height of a UILabel

蹲街弑〆低调 提交于 2019-12-14 03:42:51
问题 I would really appreciate it if you could tell me how I could set the height of a UITableViewCell depending on the height of a UILabel. My current code to set the UILabel's height is: cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; cell.textLabel.numberOfLines = 0; cell.textLabel.text = [self getItemForKey:kSummary]; cell.textLabel.font = [UIFont systemFontOfSize:15]; cell.textLabel.textColor = [UIColor colorWithRed:54.0f/255.0f green:54.0f/255.0f blue:54.0f/255.0f alpha:1.0f]; CGSize

how to set tablecell row height automatically based on inner view outlet?

假装没事ソ 提交于 2019-12-14 03:22:09
问题 I want to set tableview cell height automatically to show the label completely without happening like that? Any help? 回答1: There are 2 things that you need to do: 1st thing: Set AutoLayout for it. 2nd thing: implement these code: self.tableView.rowHeight = UITableViewAutomaticDimension self.tableView.estimatedRowHeight = 100 You can see more from my project: https://github.com/khuong291/Yelp 来源: https://stackoverflow.com/questions/33891244/how-to-set-tablecell-row-height-automatically-based

How to subClass UITableViewCell and use it to not clear UILabel background color on UITabeViewCell selected?

那年仲夏 提交于 2019-12-14 01:10:46
问题 In my app, I use a label to display a specified color by set background color in a customized UITableViewCell (because this color maybe changed according incoming data from internet), after viewDidLoad, everything is ok, but when this cell is selected (highlighted) the color is cleared. After searching, I found out that some someone have to subclass UITableViewCell and overwrite setHighlight method to not clear label background color. I have tried but unlucky. So Does anybody know how to do

Displaying labels with different background color in grouped tableView ? [closed]

怎甘沉沦 提交于 2019-12-13 23:23:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Hi friends. i Need to display the labels in a UItableView. How can i do that. Kindly refer the screenshot. 回答1: You can use the UITableViewCellStyleValue1 style of UITableViewCell. Use Custom view for the section header. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

how to display results from a method in UILabel

点点圈 提交于 2019-12-13 22:00:11
问题 Using the following code I am connecting to Google API and when I click the button the result of the following method been called will display on label field. My question is how to display more methods in a label field? For example I want to display some 4 methods or multiple results in Label field. In the code below I'm just calling one method and displaying only one result. I want to display more results or multiple results something similar to Google search. // .h file { IBOutlet UILabel*

How to Show custom Emojis Url link in Labels iOS

半城伤御伤魂 提交于 2019-12-13 21:47:02
问题 How to show Emojis url link in label. Emojis Unicode format is showing properly but when we show emojis url link its not showing its show same URL link. I am using this code for showing Emojis:- NSString *html = msCommentObj.mCommentText; NSAttributedString *attr = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute:@(NSUTF8StringEncoding)}

How to toggle visibility with the UILabel in UITableViewCell?

99封情书 提交于 2019-12-13 20:18:37
问题 I have this chunk of code in my ViewController named PlayViewController : words = [String]() func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellIdentifier = "PlayTableViewCell" guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? PlayTableViewCell else { fatalError("The dequeued cell is not an instance of PlayTableViewCell.") } // Configure the cell... cell.wordLabel.text = words[indexPath.row]