uilabel

Find UILabel in UIView in Swift

北慕城南 提交于 2019-12-19 05:56:34
问题 I'm trying to find my UILabels in my superview of my UIViewControllers. This is my code: func watch(startTime:String, endTime:String) { if superview == nil {println("NightWatcher: No viewcontroller specified");return} listSubviewsOfView(self.superview!) } func listSubviewsOfView(view: UIView) { var subviews = view.subviews if (subviews.count == 0) { return } view.backgroundColor = UIColor.blackColor() for subview in subviews { if subview.isKindOfClass(UILabel) { // do something with label.. }

Hebrew text showing rectangle in iOS on UIlabel?

佐手、 提交于 2019-12-19 03:58:33
问题 I have hebrew text and when I am showing on UILabel it showing some rectangle. please help. Actual Text :- בָּרוּךְ אַתָּה יְיָ, אֱלֹהֵֽינוּ מֶֽלֶךְ הָעוֹלָם, בּוֹרֵא פְּרִי הָעֵץ out put :- UPDATE :- I have created the UILabel Manually using storyboard xib and set font name and rectangles gone but when i using on programatically created UILabel it is not working.I double checked Font Name is fine .Any idea? Font is :- Arial Hebrew(family name) ArialHebrew-Bold (font name) ArialHebrew (font name) 回答1

Memory leaks when assigning text to UILabel (iOS, Swift 4, Xcode 9)

霸气de小男生 提交于 2019-12-19 02:58:26
问题 I've been working on a new app with no storyboard. All went fine until I tested my application with Instruments: it leaked every time I assigned a string to a label. When I worked with a storyboard, I didn't have leaks like that. I have read the following resources to find the answer: UILabel memory leak? memory leak in cell with UILabel with ARC Instruments show "_NSContiguousstring" memory leak when scrolling UITableView Potential Leak, assigning NSString-Property to UILabel iOS: Debugging

How to resize text (font) to fit in UISegment of UISegmentedControl?

做~自己de王妃 提交于 2019-12-19 02:26:48
问题 Is there any way to reduce font size that can be fit in single segment of UISegmentedControl ? Have tried many thing something like, [[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] adjustsFontSizeToFitWidth]; [[UILabel appearanceWhenContainedIn:[UISegmentedControl class], nil] setMinimumScaleFactor:0.5]; AND NSArray *arr = segment.subviews; // segment is UISegmentedControl object for (int i = 0; i < arr.count; i++) { UIView *aSegment = [arr objectAtIndex:i]; for (UILabel

Removing a UILabel when dragged to an image [closed]

纵饮孤独 提交于 2019-12-18 18:28:31
问题 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 . I have a UILabel which i added a pan gesture recognizer to and I also have a trashcan image on my view using the UIImage view. I want to delete the UILabel from my program view every time i drag the UILabel to the trashcan image. 回答1: I assume you want to do something like this: I'll show you how to implement

UILabel text not automatically resized using Auto Layout

一曲冷凌霜 提交于 2019-12-18 14:57:07
问题 I'm trying to implement a constrained UITableViewCell subclass and everything is working perfectly, except for the UILabel . The constraints that I've set up are definitely being enforced, but the text inside of the label does not resize to a smaller font size when the constraints clash. Instead, the height of the UILabel gets truncated and the font remains the same size, meaning the letters get cut off at the top and bottom. Is there some method I have to call in order to get this to work? I

Is it possible to vertically align text inside labels with a “large” frame

二次信任 提交于 2019-12-18 13:59:31
问题 In my application I have multiple tableviews with custom cells. Some of the text in the cells are spread out on between 2-4 lines so the height of the label is large enough to contain the content. However on iPad the screen is larger and I want the text to appear at the top left point of the label, not in the middle as it do when you use numberOfLines property. I know you can horizontally align the text, but it must be possible to align the text to the top left also? Or is it impossible.

How to get date and time to show a clock in UILabel

守給你的承諾、 提交于 2019-12-18 13:26:01
问题 I'm new to swift (and programming in general) and right now I'm working on a project that I'd like to display a clock in a label. right now I have this in my model: class CurrentDateAndTime { let currentTime = NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: .MediumStyle, timeStyle: .MediumStyle) } and then call it into the label with this code in my view controller: @IBOutlet weak var currentTimeLabel: UILabel! let currentTime = CurrentDateAndTime() override func viewDidLoad() {

Swift 3 Create UILabel programmatically and add NSLayoutConstraints

佐手、 提交于 2019-12-18 13:24:10
问题 Hello I am trying to create a label programmatically and add NSLayoutConstraints so that it is centered in the superview regardless of screen size and orientation etc. I have looked but just can't find an example to follow. Here is what I have: let codedLabel:UILabel = UILabel() codedLabel.frame = CGRect(x: 100, y: 100, width: 200, height: 200) codedLabel.textAlignment = .center codedLabel.text = alertText codedLabel.numberOfLines=1 codedLabel.textColor=UIColor.red codedLabel.font=UIFont

How to know the length of NSString that fits a UILabel with fixed size?

谁说胖子不能爱 提交于 2019-12-18 12:32:45
问题 I know NSString has methods that determine the frame size for it, using NSString UIKit Additions, sizeWithFont...... How about the other way around? I mean if I have a fixed frame size, how do I know how many characters or words for a NSString that can fit into it? If I know this, I can cut off the NSString easily. thanks 回答1: It might not be the most elegant solution, but you could do something like this: - (NSString *)string:(NSString *)sourceString reducedToWidth:(CGFloat)width withFont: