sizetofit

ios - SizeToFit on UIImageView not working

回眸只為那壹抹淺笑 提交于 2020-01-02 06:19:13
问题 I have a UIImageView which loads in images from the documents directory on the ios file system . The problem is that when I call [imageView sizeToFit]; It does not work. I think it is because the image hasn't loaded fully at that point and so the sizeToFit part is called before it has the image width & height. Could someone point me in the direction of a fix please. Here is my code: imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.image = [UIImage imageWithContentsOfFile:

ios - SizeToFit on UIImageView not working

偶尔善良 提交于 2020-01-02 06:18:15
问题 I have a UIImageView which loads in images from the documents directory on the ios file system . The problem is that when I call [imageView sizeToFit]; It does not work. I think it is because the image hasn't loaded fully at that point and so the sizeToFit part is called before it has the image width & height. Could someone point me in the direction of a fix please. Here is my code: imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.image = [UIImage imageWithContentsOfFile:

Resize UItextview according to it's content in iOS7

夙愿已清 提交于 2019-12-29 04:02:29
问题 I'm trying to resize a text view according to content & also it's sibling and parent container. Below code is working fine in iOS 6 if (/* less than ios 7 */) { CGRect frame = _textView.frame; CGSize conSize = _textView.contentSize; CGFloat difference = conSize.height - frame.size.height; frame.size.height += difference; _textView.frame = frame; UIScrollView *parentView = (UIScrollView *)_textView.superview; // adjust views residing below this text view. // sibling view UIView *belowView = //

UILabel text to fill in the frame width

好久不见. 提交于 2019-12-22 08:36:14
问题 I want to build typography poster using UILabel left and margin: 25 320(device width) - 50(sum of the margins) = 270(label width frame) The font size of each label should change in order to fit in 270 frame width I try with sizeToFit() , adjustsFontSizeToFitWidth=true var margin = 0; let label = UILabel(frame: CGRectMake(25 , 72, 270, 70)); label.backgroundColor = UIColor.clearColor(); label.textAlignment = NSTextAlignment.Left; label.textColor = UIColor.blackColor(); label.numberOfLines = 1;

CATextLayer wrapped sizeToFit?

六月ゝ 毕业季﹏ 提交于 2019-12-22 04:17:09
问题 If I set textLayer.wrapped = YES , how do I resize textLayer to contain the wrapped text? I.e., how do I get the new height of the textLayer ? Basically, I want something like -[UILabel sizeToFit] . 回答1: The first thing you need to do is get the size of the text. Thankfully, the NSString UIKit Additions Reference offers a method to do exactly that: - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode That will give you a CGSize that

UITableView with UILabel SizeToFit get mess when Scrolling

戏子无情 提交于 2019-12-21 11:05:03
问题 Hi everyone I have problem with my tableview , i make Cell with uilabel with SizeToFit and then calculate the UILabel Height for set the cell Height everything work well except when i scrolling my tableView the text get weird like one char per line: My TableViewVell Method is: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier

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

AdjustsFontSizeToFitWidth vs. SizeToFit

本小妞迷上赌 提交于 2019-12-10 11:29:29
问题 I'm using SizeToFit because I don't have to specify the Frame property to have an adaptive size of the UIButton / UILabel . In my case it's a button on a toolbar. Now I made the following observation: If I use AdjustsFontSizeToFitWidth together with SizeToFit than the font size isn't adapted anymore. So I can Specify a Frame and use AdjustsFontSizeToFitWidth Use SizeToFit but don't have the adjustable font size anymore Do you also have this problem? How do you circumvent this problem? How to

ios - SizeToFit on UIImageView not working

流过昼夜 提交于 2019-12-05 14:19:31
I have a UIImageView which loads in images from the documents directory on the ios file system . The problem is that when I call [imageView sizeToFit]; It does not work. I think it is because the image hasn't loaded fully at that point and so the sizeToFit part is called before it has the image width & height. Could someone point me in the direction of a fix please. Here is my code: imageView.contentMode = UIViewContentModeScaleAspectFit; imageView.image = [UIImage imageWithContentsOfFile:[FileOperations getLibraryPath:[NSString stringWithFormat:@"%d.png", listData.imageId]]]; [imageView

CATextLayer wrapped sizeToFit?

橙三吉。 提交于 2019-12-05 03:26:04
If I set textLayer.wrapped = YES , how do I resize textLayer to contain the wrapped text? I.e., how do I get the new height of the textLayer ? Basically, I want something like -[UILabel sizeToFit] . The first thing you need to do is get the size of the text. Thankfully, the NSString UIKit Additions Reference offers a method to do exactly that: - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode That will give you a CGSize that you can then use to set the frame of your UILabel or whatever subclass of UIView that you're using. So,