Setting content mode of UIButton not working in XCode6 - uibutton

I have previously had no issue setting the content mode of a UIButton from the storyboard, I would just set the background image of the button and then under the view section I would set the mode to AspectFit or which ever mode was relevant.
When I try the above steps now in XCode 6 it makes no difference, the image remains scale to fill always.
I've also tried setting the default image instead of the background image and setting the content mode in code like this:
self.myButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
But it does not make a difference either, it remains scale to fill always.
Have apple changed the way this is done in XCode 6 or is this just a red herring and I'm missing something else?

Related

iOS 8.0.2 and iPhone plus when I set UIButton backgroundImage in XIB,UIButton become bigger though this button have autolayout with height and weight

iOS 8.0.2 and iPhone plus when I set UIButton backgroundImage in XIB,UIButton become bigger though this button have layout with height and weight after running
UIButton in xcode:
and layout :
but running in iPhone plus iOS8.0.2:
but in other iPhone like 5s,6 this button is ok!!!
the backgroundimage like this :
i have setup (https://github.com/usamaiqbal83/TestingProject) a repo for your case, it is not happening for me you can compare your setup with mine . i checked it on simulator
or if i am not able to understand your scenario clearly, kindly setup a repo i will gladly take a look.
when I set the Image like this:
it is working .
I do not what has happen, but just it is.
any body know why it is?

Animation artifacts when NSImageView intersects NSTextField in an NSPopover

I'm presenting a view in an NSPopover, using code based on this sample code.
The view, and all of its sub-views, are layer-backed. There's a single NSImageView, and several non-editable NSTextFields. The text fields backgroundColors are set to [NSColor textBackgroundColor], and their textColors to [NSColor textColor]. In this way, the text is black if one is using the normal theme, and white if one is using the "dark menu bar and Dock" option (which I'll refer to as "dark theme" from now on). This all works fine, and it looks a little somethin' like this:
Light theme:
Dark theme:
The problem comes when I animate the NSImageView up off the view. As it intersects with the NSTextFields, the image appears to blend with the text fields in an unappealing manner. It happens in both light and dark themes, but it's more icky-looking (it's a technical term) in the dark theme. Dig it:
The code to animate it looks basically like this:
CABasicAnimation* positionAnimation = [CABasicAnimation animationWithKeyPath:#"position"];
positionAnimation.fromValue = [NSValue valueWithPoint:fromPoint];
positionAnimation.toValue = [NSValue valueWithPoint:toPoint];
positionAnimation.duration = imageAnimationDuration;
[self.imageView.layer addAnimation:positionAnimation forKey:#"position"];
self.imageView.layer.position = toPoint;
What have I tried? Oh, what haven't I tried?
First off, my own views don't have any kind of NSVisualEffectView going on. But it seems that NSPopover adds that on its own; you can clearly see my desktop bleeding through the popover in the animation above. That's fine; it's actually a nice effect. But, thinking that my NSImageView was trying to be vibrant, I subclassed NSImageView just to return NO from allowsVibrancy. No change in behavior.
Next, I subclassed NSView to return NO from allowsVibrancy, and made the parent view of my view an instance of that. No change in behavior.
My NSTextFields are set with drawsBackground = NO, so I changed them to YES. No change in behavior. Then, leaving drawsBackground = YES, I set both text field's backgroundColors to [NSColor clearColor]. Here's where it gets weird. This does make the weird drawing go away, but it changes the text color of one of the text fields (the smaller one) to black. Wut? See below.
I gave up on the background colors, and started messing with the text colors. I found that if I set the textColor of the text fields to a discrete color (say, [NSColor blackColor] or [NSColor whiteColor], then the weird drawing problem also goes away. It seems only to get weird when using colors which adapt with the theme such as [NSColor textColor]. That's super lame, because the whole point of using something like [NSColor textColor] is that it adapts to the theme. I could probably hack around and figure out what theme is active and set the colors manually, but I really don't want to go that route if I can help it.
I promise there's a question in here somewhere, and, mercifully, here it is:
How can I fix the animation issue shown above, while still using colors which properly adapt to the current theme?
Sample project on GitHub.
Edit:
The desired result is to have no blending between the image and the text. Something like this:
The image I used in the sample app here maybe isn't the best example to convey the sheer yuckiness of the animation I'm seeing in my actual app. The image in the sample is already mostly white, while in my actual app it's mostly black, and it truly looks horrible when blended with white text.
Visual Effect Views (like used in NSPopover) are totally messed up in OS X Yosemite and they are causing your problem here. It is not your fault, these views are totally buggy.
A workaround on Yosemite should be to set the appearance property of each NSTextField to NSAppearanceNameAqua. Because if the labels don't try to do some weird vibrancy effect, they can't mess things up. The labels still look the same and the strange effect is gone.
My words in code:
self.titleLabel.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
self.descriptionLabel.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
Luckily NSVisualEffectView's are working fine now in El Capitan. So your code should work fine there..

xCode6 how to apply blur/vibrancy effect properly in storyboard?

I'm trying out the new "Visual effect with Blur" in xCode and am noticing the visual artifact in the attached image. I tried different combinations of constraints and see that
Here's the issue I'm seeing - the UILabel's frame is outlined in a different color. How can I make sure that the label has a transparent background, but still gets the vibrancy effect when using "Visual Effect with Blur and Vibrancy"?
Make sure both the UILabel and any view behind has Background set to Clear/Default color.

Stretching background image in UITextField. Is it a bug?

I was trying to add a background image to UITextField through Storyboard, but discovered a strange bug. When I'm trying to change Stretching under the View section of the Attributes inspector, the background image in the textfield does not change at all. I have also tried to do this with .xib file, but got the same result. And also I got the same result in UIButtons.
Try it yourself. Put a textfield into a view controller and add a background image to it and set stretching to 0.5, 0.5, 0, 0 You should get nothing.
So, is it a real bug or I'm doing something wrong?

Can a UIViewImage draw its image outside its frame?

When making a photo viewer app found that our UIImageView controller is drawing its image outside its frame when the content mode is different neither ScaleToFill nor Aspect Fit.
Trying to understand why; I isolated the problem making a new project which only has a UIImageView with the following frame (50,50,100,100). The image size contained in it is (4592,3056).
After running the app, with the content mode set to ScaleToFill and AspectFit it all worked as expected:
But after setting the contentMode of the UIImageView to TopLeft, the image is drawn outside its frame, the odd thing is that the log from the frame after all has been drawn is still the original {50,50,100,100}.
I've try to understand the issue by moving the Autoresize, the clips and the content mode of the UIViewController but the result is the same.
set clipToBounds = YES on the view.
its NO by default because that makes drawing way cheaper