UIButton resizes when I change font? - iphone

I have several UIButtons, I'm trying to bulk change the font for all of them in InterfaceBuilder, but when I change the font, they auto-resize to the original image dimensions instead of what I had them set to, screwing up the layout. I would like to avoid having to resize and move everything around again any time I change the font. I could just set the font in a loop in code, but it seems redundant.
Is there a setting to stop this from happening?

This issue doesn't seem to occur in Xcode 4.0 or above.
Should anyone still be using a lesser version of Xcode I would suggest updating.

Related

Some Border Types in NSImageView Not Appearing

I've looked in previous posts in SO and elsewhere for an answer but no luck. I'm putting images in an NSCollectionView as well as just a single image itself but the only border that seems to work is the grey Bezel border. Other types that are available don't show up, like Button or Groove. This is true no matter what scaling option I use, or even if I use it in code. I'm using NSImageView.imageFrameStyle.
I hope someone has some insight into this. I didn't provide any code since I didn't think that's necessary. Using Xcode 10.1, Swift 4.2. Thanks for any help.

How can I prevent Xcode from changing the color of my buttons?

So I've done a button for my iPad app, and I saw something strange. When I run my app in the iOS 5 simulator, it changes the color, and the lines of my button become discontinuous. But when I push it, the button comes back to the right color, and the lines are ok. I think it's something that Xcode does automatically with any button, and I don't find the way to cancel it. Thank you for helping!
PS: The button code is so simple:
IBOutlet UIButton *button;
This is what it should look like:
And this is how it looks in the simulator:
Both tams and JacobFennell have good points, but you should also note that graphics are often represented much differently on the simulator than on a real device. You should try running your app on a device and see if the problem persists; I have had many 'problems' with custom buttons which turned out just to be improper rendering on the part of the simulator.
Since you are using the Interface builder, make sure that you are setting the button type to custom and that you have changed the behavior for all of the states. Under the dropdown menu of where you can set the type they also have StateConfig, where you can configure the look and text of your button for all of its different states: highlighted, default, disabled...Check that those settings are correct as well.
Hope this helps!
Tams
Your button frame size doesn't seem to match the size of your image. Your art should match the (button/view) frame size pixel for pixel, otherwise you may get blurry images and scaling representation artifacts.
Else, you can change the view content mode (UIViewContentMode) of the frame from UIViewContentModeScaleToFill to UIViewContentModeTopLeft

UILabel text on iPad not resizing

I have iOS 4.3 installed on my iPad. I'm noticing that my text in my UILabels is not resizing. In other words, I'm adding letters, but it's just truncating. Same settings work find on iPhone also running 4.3. I'm perplexed. I've made certain that "Adjust to fit" is checked on the label properties. I've even set it in the code with .adjustsFontSizeToFitWidth and even tried calling sizeToFit.
None of these let the text resize.
Does anyone else have this problem?
Any ideas?
My next solution is going to use this: Check if label is truncated to try and manually resize the label text.
I finally figured it out. I'm using OHAttributedLabel. I had intended to do some things with color in my labels and have not yet gotten around to it. It finally dawned on me that was the only difference from previous iPad versions and from the iPhone version (I never even thought to look at the class). Turns out this OHAttributedLabel class does not support resizing yet.
Sorry for wasting everyones time. Maybe someone else will someday find this useful.
Try using CGSize eLabelSize = [yourLabel.text sizeWithFont:yourLabel.font]; to get the size of the label and then you can simply modify the yourLabel.frame.size property with eLabelSize.
This worked for me in case of iPhone.
Hope this works for you if yes do communicate..... :)
Maybe it only appears as if the label is truncating text because the label frame runs out of the bounds of its parent view, which clips to its bounds? Verify the frame of the label and the autoresizing mask.
Also, the minimumFontSize property is set low enough?

iPhone 3.1.3: All my UIButtons and UITableRowViews are now gray

Not sure how this happened, but all of the UITableRowViews and roundrect-style UIButtons in my app—spanning a dozen or so views—are now all gray instead of white.
Unfortunately, I have no idea how this happened. (In fact, I had no idea it was possible to do this.) Explicitly setting the button's or tableRowView's background color to white gets it back to normal. But it'll be a lot of work to do that to every one of my views...and I'd rather not have to do it since there's obviously something simple that caused it in the first place.
How did I break this?
Thanks very much.
Bizarre: if you add a static method into some UIColor category and call it +(UIColor*)tableViewBackground, it'll change all your tables and buttons to that color.
Must interfere with some hidden method in Apple's UIColor implementation.
I fixed my problem by simply using a different name ("viewBackgroundColor").
You could select all of them (Cmd+A or drag a rectangle) and change the background color back to white.

Customize Date Picker: How to change width & height of datepicker in iphone?

Is there any way to customize the datepicker used in iphone?
I want to change height & width of it.
Can we change the background color, font color of it?
Please help if anybody has done before.
Thanks in advance ...
The size cannot be changed. There are other questions concerning this and several ways to fake it, moving it partially offscreen or putting other views in front partially obscuring portions or adding background images to make it look larger. The best approach is to use it as-is or write a custom picker.
Or you can create your own picker ;)
I created this component that allows you to do this really easily: http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/