I am using a method to resize my UIButtons that is being erased, and not very strong for it And for other reasons, I want to get size stuff to work for YouTubebotons. What I have read online, I am not sure that this should work (it seems that it is working for some, but not the difference between style, I am using custom).
> I have a simple test code to redo this problem (I put it in deedload to see it, but there should be no difference, and my actual code is part of a larger project): UIButton * BTN = [UIButtonTypeCustom] with UIButton Button; [BTN Set Titles: @ "This is a test with a long title which will need to wrap more than one line when displayed on your small iPod in Portrait View." ForState: UIControlStateNormal]; Btn.titleLabel.lineBreakMode = UILineBreakModeWordWrap; // Errors - but nothing to change it? Cgrt r = btn.fr; R.origin.x = 0; R.origin.y = 0; R.size.width = 320; R.size.height = [btn.titleLabel.text sizeWithFont: btn.titleLabel.font constrainedToSize: CGSizeMake (r.size.width, 100000) LineBrand Mode: btn.titleLabel.lineBreakMode]. height; // Returns approximately 86 and correctly if i change the title text r.size.height = [btn sizeThatFits: CGSizeMake (r.size.width, CGFLOAT_MAX)] height; // Return 34 does not matter whether BTN.frame = R;
The way I am doing works, it works, and it works, but it is not seeking actual control for size, so it is not really safe and It has also been eroded. The SizeThatFits line is what I would like to work on, but it always depends on 34 (maybe a button's recommended / default height).
I am using the same size to resize the UILabels and there are some other controls too. I have updated them for size sizes and they work great, just UIButton does not work as others Has been doing. I'm hoping that this is a simple fix to install UIButton's property to work?
My app needs to support only iOS 8+, not older versions.
Update: Based on the comments and accepted answers here, it seems that we can get trapped with size or other sub-cross solutions ... Dang.
No comments:
Post a Comment