I'm using NSTextField in OSX, why text fields used are inconsistent, Some of them are rectangle perfectly while some of them have corner ? Please see attached screenshot.
I want it to be all square perfectly. I've already checked in IB they seems to have same attributes.
Anyone have ideas?
Related
I have a window with a textview in a scrollview and two buttons. I have added constraints at all sides, leading, trailing, top, and bottom. For the buttons I have fixed width and height, and distance to bottom and edge.
I want it to look something like this:
And this is what Interface Builder keeps giving me:
It also keeps offering to fix ambiguities by adding missing constraints, but actually clicking the button has no effect. No constraints are added. The error (and the offer to fix it) remains.
I've tried added the constraints it is asking for, although I can't see why they would be needed and at least the buttons already have (fixed) width constraints. But I keep getting errors and the window keeps getting shrunk to nothing.
When actually running the program, the window looks fine. But I suspect these autolayout errors have something to do with this problem: NSTextView in magnified NSScrollView breaks on resize
The project is here: https://github.com/angstsmurf/spatterlight/tree/helpviewtest
(The branch helpviewtest is a cut down test case created specifically for this problem.)
You have a Text view embedded in a Clip view embedded in a Scroll view, none of which have an intrinsic content size.
IB has no idea what's going to go on at run-time.
So, while everything looks great when you run this, your code will have supplied enough information to lay things out as desired.
To get it to "look right" in IB (and avoid the errors/warnings), you can give the ScrollView a Placeholder Intrinsic Content Size:
Context
I have a window with a fullSizeContentView and a transparent titlebar and hidden titlebar.
I don’t even want the titlebar, but I had to enable it to get rounded corners on the NSWindow.
Problem
An NSTextView, when placed near the top edge, doesn’t react to any clicks. It doesn‘t let me select any text, and doesn’t let me click links I added via NSAttributedString.
This issue disappears when I disable the titlebar altogether.
Any Help would be greatly appreciated. Thanks!
Big Context
I’m trying to implement little “in-app notifications” that show peripheral status updates. I considered using NSAlert but I don’t want to prevent the user from interacting with the rest of the interface while the notifications are showing, so I decided to implement it myself.
The notifications are little, non-movable windows without a titlebar. They are basically just grey rectangles with rounded corners and a shadow that draw inside the main application window and contain one or a few lines of text. The first line of text is almost entirely behind the invisible titlebar which is why I’m having issues.
The only thing I need the notifications to do besides display text is link to webpages that contain more info about a notification’s message.
I feel like I might be approaching this wrong. If you have any suggestions or ideas on how to solve the problem, I’m eager to hear them. Thanks!
I finally figured it out!
I nailed it down to the contentInsets of the NSScrollView. (which your are for some reason forced to have around your NSTextView when creating it in Interface Builder)
The contentInsets were automatically being set to account for the invisible titlebar, even though the docs say that NSScrollView - automaticallyAdjustsContentInsets (which is set to YES by default and which I assume was causing this) doesn't do automatic insets for transparent titlebars.
After programmatically setting the scrollView's contentInsets to 0, everything works great!
In Objective C, you can set your scrollView's contentInsets to 0 like this:
NSScrollView *scrollView = (NSScrollView *)self.textView.superview.superview;
scrollView.automaticallyAdjustsContentInsets = NO; // Doesn't remove insets // Probably calling this too late
scrollView.contentInsets = NSEdgeInsetsMake(0, 0, 0, 0);
Here's a working example.
Hope this helps!
I am having problems with animating an UIView.
Everything is actually pretty basic:
My storyboard, because it easier to show a pic than to explain everything.
As you can see, there is a white UIView in the middle ( behind the gray label that says "Navi ein" ). It has to TextFields and one button in the right bottom corner.
I now added an animation to this UIView, so when the user clicks the button "Navi" (placed in the navi.-bar, top left), the UIView flys in from the top to the center (centerY-constraint and alpha animation, very simple).
The animation works for the UIView, but the TextFields and the button are not shown after it. My question is: why? I would really appreciate your help! :-)
Please let me know if you need some code extracts, but it shoudn't be necessary.
EDIT: I now found the text fields and the button in my View Debugger, I just forgot to uncheck "Only show displayed views". But how to figure out what makes them disappear (or not even appear) when the app launches?
View Debugger
I am so sorry! I just saw that I set all three items to hidden in my code.
I've never thought about that so far, I just looked in my storyboard.
So the problem is solved, I just deleted the lines "streetTextField.isHidden = true" and so on.
Nevertheless, I think it is good to hear and to see that some problems that seem to be hard are very easy to solve.
As you can see in the screenshot below, the NSCollectionView I used has some kind of border (the thin gray lines) I want to get rid of. Can somebody tell me how to achieve this? I already tried subclassing the NSCollectionView and tried to overwrite it in the drawRect: by using [[super layer] setBorderWidth:0.0f]; but this did not work.
Searching on Google, SO and the Apple Documentation did not help either. So did anyone achieved this already or knows where I can find an example of how to do it?
Thanks in advance,
Björn
The collectionView is nested in a NSScrollView, which has a borderType property.
You can get rid of the border by simply setting its border type to NSNoBorder.
self.collectionView.enclosingScrollView.borderType = NSNoBorder;
From story board:
Select the scroll view from story board
Then choose no boarder from Attributes Inspector
For Swift 3 :-
collectionView.enclosingScrollView?.borderType = .noBorder
I have been trying to create a simple swipe transition. However buttons seem immune to any CAAnimation that crops.
I am trying to get it so that a bar moves across the screen and as it goes over the button it removes the part it has just gone over.
I have tried bounds.width, size.x and many other key-value paths to achieve the affect but I haven't got what I wanted. It just relocates the text which always remains entirely visible
I have also tried changing the UIButton to a UIImage but the text does not seem to print on a UIImage.
I tried using masks too but I have heard they should be used as infrequently as possible as they consume the phones resources. I didn't really get very far with this either anyway as I hadn't used them much before.
I also tried placing it in a container view and then change the dimensions of that but again all of the text remained entirely visible.
I know I could have a view hide the button but I am trying to reveal the view behind as the bar swipes.
Does anyone have any suggestions of how to achieve a swipe transition on a UIButton?
Help would be much appreciated.
Thanks
I think what you're looking for really is a mask. See the tutorial here:
http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
What I'd do in your situation is create a custom UIButton class, and add a mask as in the tutorial, then animate the position of the mask. Slide the mask of, nothing shows. Slide it on, part shows until the whole thing is visible.
Edit: I haven't really heard anything about hogging resources, especially since it appears to be simple core graphics.