uilabel

change string with picture in swift

女生的网名这么多〃 提交于 2020-01-06 04:17:10
问题 I have a String in a UILabel and this string includes one or several emoji but only the name like ":cool:" or ":crazy:". How can I replace the word in the String with the .png ? func checkString(pString: String) -> String { var replaced = pString //get the String var found = "" var image = UIImage() //Emoji for i in 1...bib.count { //bib = array(Int:String) with all names of the Emoji if pString.range(of: bib[i]!) != nil { found = bib[I]! //picBib is a array(String:String) with the Emoji name

How can I calculate font size for my UILabel?

断了今生、忘了曾经 提交于 2020-01-06 04:01:05
问题 I have a UILabel measuring 984x728 px with variable text. How can I calculate the maximum font size to fit the UILabel ? 回答1: Create a font larger than you would ever want (48 points is probably good). Then use this: CGFloat maxFontSize; [string sizeWithFont:font minFontSize:0 actualFontSize:&maxFontSize forWidth:maxWidth lineBreakMode: UILineBreakModeClip]; maxFontSize will hold the largest size less than 48 and greater than 0 that will fit within maxWidth . 来源: https://stackoverflow.com

iOS to Android: How to display a TextView

狂风中的少年 提交于 2020-01-06 03:41:17
问题 I have a background in iPhone development, which may be a cause of some of my confusion with Android, which I am very new at developing. My question is this: How to I create two TextViews , and specify their exact location on screen? For example, on the iPhone, I would create a UILabel, generate a rectangular frame that specified the label's size and position, and then set this rectangle to the frame property of the UILabel. If you can help me understand the similarities with Objective C and

how to change uilabel text size in different iPhones

自闭症网瘾萝莉.ら 提交于 2020-01-06 03:09:06
问题 Is there a way to change UILabel text size for different screen sizes? I need the text to be bigger in I-phone 6 and 6+. Can i do this? Would the correct way to do this will be to check screen height and then changing the text size? Thanks 回答1: if (self.view.frame.size.width == 320){ //iPhone 2G, 3G, 3GS, 4, 4s, 5, 5s, 5c label.font = UIFont(name: "....", size: 20) } else if (self.view.frame.size.width == 375){ //iPhone 6 label.font = UIFont(name: "....", size: 25) } else if (self.view.frame

小总结

拥有回忆 提交于 2020-01-06 02:48:04
本文目录 0.UIView常用的属性和操作 0_1.UIView常见的属性 0_2.UIView状态 0_3.UIView常用的方法 1.文本框UITextField和文本视图UITextView 1_1.文本框UITextField(几乎包含了iOS控件的所有的通用属性) 1_2.文本视图UITextView 1_3.键盘输入的处理程序 2.标签UILabel和按钮UIButton 2_1.标签UILabel 2_2.按钮UIButton 3.滑块UISlider、步进UIStepper和图像UIImageView 3_1.滑块UISlider 3_2.步进UIStepper 3_3.图像UIImageView 3_4.图片浏览器 4.开关控件UISwitch和分段控件UISegmentedControl 4_1.开关控件UISwitch 4_2.分段控件UISegmentedControl 4_3.图片排序 5.工具栏UIToolBar 5_1.工具栏UIToolBar的使用 5_2.UIBarButtonItem 说明: 这个专题,是介绍了一些常用的普通空间的属性和使用,包括:UITextField、UITextView、UILabel、UIButton、UISlider、UIStepper、UIImageView、UISwitch、UISegmentedControl

How to drag a label and drop on UIToolbarItem in iphone

梦想与她 提交于 2020-01-05 10:30:53
问题 I am facing problem to drag and drop UILabel . How to drag label(Move This) and drop on any one of UIToolBar item (i.e., 1 or 2 or 3 ...) that button title should change as label text. Check image for this question 回答1: Use custom button as a label and then use this code as : UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:self action:@selector(btnTouch:withEvent:) forControlEvents:UIControlEventTouchDown]; button.tag = -1; button.titleLabel.text = @"Move

Is there a way to add custom fonts to Xcode to be available from a storyboard? [duplicate]

别等时光非礼了梦想. 提交于 2020-01-05 10:13:09
问题 This question already has answers here : Designing labels/text views with custom fonts in Interface Builder (8 answers) Closed 5 years ago . I know how to add custom font files to be shipped with an iOS app. I can then customize the label font from code using code like this : UIFont* font = [UIFont fontWithName:@"League Gothic" size:42]; self.topLabel.font = font; My concern is that such customization will "infect" all of the project and may require some significant rework later on. Is there

iOS: Algorithm to center a word in a sentence inside of a UILabel

ⅰ亾dé卋堺 提交于 2020-01-05 04:55:16
问题 I need to center a particular word in a sentence by truncating the beginning and endings of a long sentence inside of a UILabel, For example NSString mySentence = @"This is my very long sentence to give you an example of what I am trying to do.. And its still going.."; NSString myWord = @"example"; <Algorithm goes here> Should display: "...sentence to give you an example of what I am trying to..." If the word is closer to one end or the other, just do your best to center and display an

UILabel text duplicates in PDF when containing a certain character

帅比萌擦擦* 提交于 2020-01-05 03:43:09
问题 I'm generating a PDF something like: UIGraphicsBeginPDFContextToFile layer.render(in: context) UIGraphicsEndPDFContext Yesterday, I found a fix to make all text vector-based (basically this answer https://stackoverflow.com/a/9056861/897465). That worked really well, text is vectors and searchable, etc. Except for one irritating thing. Everytime a UILabel contains the character "Å", the text is kind of duplicated in the PDF, like the image below. Probably there are other characters as well the

UILabel Refresh

ぐ巨炮叔叔 提交于 2020-01-05 03:01:50
问题 I have looked into this, but I’m still not quite clear how to do it. I have a UILabel. I would like to write out a word... letter by latter. It goes through each letter, then at the end the entire word shows up. At first I thought it was just because it was too fast, so I put in a delay with something like this. typedWord.text = [typedWord.text stringByAppendingString:@"C"]; future = [NSDate dateWithTimeIntervalSinceNow: letterPause ]; [NSThread sleepUntilDate:future]; Then I read that it may