I'm creating an NSWindow with title bar (.titled) or tool bar and I tried to adopt a new look for macOS Big Sur.
For example, the titlebar effect of TextEdit is perfect:
As you can see above, when I hover above the title bar, the titlebar's separator shows with transition. Then the separator disappeared after the mouse left.
I found NSTitlebarSeparatorStyle in Apple Documentation:
The automatic style doesn't provide an auto changing separator.
So how can I achieve this? Any good advise? :)
The .automatic style does provide the separator hover effect, but only when the window's content view consumes the full size of the window, that is, the .fullSizeContentView style mask.
So to have the effect you want, you will need to add .fullSizeContentView to your window's style mask:
window.styleMask.insert(.fullSizeContentView)
Related
I've created a blank project, and added a toolbar to the main window. To it, I've added two "Textured Rounded Button[s]" from the object library. I've left one as-is, and the other I've customized by setting the image.
At runtime, they look correct, with the correct width automatically inferred:
However, this doesn't match the interface builder preview:
The button's width was set when it used to have the title "Textured Rounded", but it didn't readjust its width after removing the title and adding the icon.
It bugs me that my IB preview and runtime UI don't match. Of course, I can hand-tweak the button width, but that:
Suggests to me I'm doing it wrong
Is going to break in the future, similar to how my mis-configured toolbar buttons started looking wonky in Big Sur.
What's the correct way to add a button to a toolbar, in interface builder?
I am working on a macOS app and I programmatically adding NSToolbarItems following Apple's documentation and I am adding the new NSTrackingSeparatorToolbarItem to support the new macOS 11 toolbar look and feel.
The tracking separator seems to work fine as long as I don't resize the split view below a certain width, then the separator breaks out and just looks out of place.
The tracking separator working as expected
And the separator breaking out when the split view size is below a certain width.
Is there a way to avoid this?? I know that I can set a minimum size for the split view, but is there a way to keep them synchronized (I don't want to hard code a minimum width)?? Especially if the user adds toolbar items dynamically.
Thanks in advance.
Ok I think I figured it out...
I noticed a interesting behavior when playing around with the Mail app, which when the preview pane is showing the NSTrackingSeparatorToolbarItem follow the resizing of the split views but the moment the preview is collapsed the toolbar changes appearance and becomes like a static toolbar. Furthermore the NSTrackingSeparatorToolbarItem stays in place and looks just like a normal toolbar separator (like you might find on other OS's).
So I played around in IB with my toolbar and discovered my error, my NSWindow had the titlebar set to transparent!!
I unchecked the option and voila I could replicate the look and feel of the Mail app, all automatically.
this property has to be set to false in NSWindow
#available(macOS 10.10, *)
open var titlebarAppearsTransparent: Bool
And of course the toolbar style should be set to unified
#available(macOS 11.0, *)
public enum ToolbarStyle : Int {
// The default value. The style will be determined by the window's given configuration
case automatic = 0
// The toolbar will appear below the window title
case expanded = 1
// The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible
case preference = 2
// The window title will appear inline with the toolbar when visible
case unified = 3
// Same as NSWindowToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window
case unifiedCompact = 4
}
Please note that the break out behavior still occurs but when this happens the toolbar changes look and feel and you don't see any ugly split view divider line like I had experienced. Hope this helps anyone else who might run into this issue.
I am using storyboards to make a search bar using UISearchBar. I am trying to make it look like this:
However this is what I end up getting:
I've added code to change the bar's dimensions and set a minimum font size for the text (for auto layout) and add corner radius. The only code that works is the corner radius unfortunately.
searchBarOutlet.layer.cornerRadius = 10
searchBarOutlet.layer.borderWidth = 304
searchBarOutlet.clipsToBounds = true
You can set the search bar style to "Minimal" in the properties inspector, I think that's more close to what are you looking for, regarding the the font size and autolayout issues I think there is no way to access those properties in the UISearchBar, but there are workarounds like the one specified here Change the font size of UISearchBar
The other workaround you can try it's making your own "loook a like" search bar, which shouldn't be that hard, maybe the hardest part will be to add small icon to the left of the placeholder
I am developing a RCP4 application, where I used toolbar. In some system toolbar and part label are same alignment. But some system toolbar is coming another line of part tab. Why this kind of things are happening?
It looks like this is because the height of the icons in the tool bar are bigger than the calculated height of the part tab area. This causes CTabFolder to move them to the next line.
You can set the height of a CTabFolder in the CSS using swt-tab-height. For the part stack folder this may work:
.MPartStack
{
swt-tab-height: 22px;
}
Regarding the SMS compose view as show in the picture below:
alt text http://www.kennethlund.dk/wordpress/wp-content/uploads/2008/08/iphone_sms.jpg
I have two questions:
1) How is the text entry box implemented? There are no standard control from the API and the box is smart enough to resize when you press enter OR when the text is too long. Also the bar resizes with it. How is this done with the least coding?
2) How to code it such that when the keyboard shows up the whole view shifts up? Typically when the keyboard shows, it goes over your current view.
Searching stackoverflow for "uitextView size" produces these results:
How do I size a UITextView to its content?
Resizing UITextView
Searching stackoverflow for "keyboard iPhone" produces this result:
Programmatically align a toolbar on top of the iPhone keyboard
TTTextEditor is an autosize text box, which is part of the three20 framework