View-based "Source List" NSOutlineView font smoothing issue - objective-c

I'm migrating a cell-based NSOutlineView to a view-based one, and I'm noticing that text is being rendered differently in the view-based outline view. See this image:
Why the difference? Some background information that may help?
This is on Mac OS X 10.7.4
The NSOutlineView's highlight style is Source List
The NSOutlineView's background color is transparent, and the background is being drawn by an underlying view
In the view-based outline view, the cell text is being drawn by an NSTextField in an NSTableCellView
Nothing in the view hierarchy is, to my knowledge, layer-backed
I think this describes a similar issue: Weird font anti-aliasing in view-based NSOutlineView, but the solution did not work for me, as (I don't think) any of the cell views or text fields are layer-backed.

Update: I've figured it out. In Interface Builder, if I select the text field in the table cell view, check "Draws Background," and set the background color to clear (RGBA 0,0,0,0), the text appears smoothed the same way as it would in a cell-based outline view.
So I don't think it's an NSOutlineView issue in particular. I don't know the internals of Cocoa text rendering, but I'm assuming it's because font smoothing will vary based on what kind of background the text is being drawn on.

Related

OS X chat app with resizable bubbles

I'm building chat application for Mac OS, similar to iMessage. I wonder, how can I implement resizable text views in bubbles. I mean, when I resize chat window bubbles with text will resize to. Any ideas, links will be very useful. Thank you for help)
For text resizing, you use auto layout. If you have an NSScrollView containing MYBubbleViews containing NSTextViews, you can add NSLayoutConstraints using the leftAnchor and rightAnchor properties of the scroll view's content view and those of the bubble view, and add constraints between all edges of the text view and bubble view. Then pin the bubble views to the top/prev view.
Also make sure you set the NSTextView to wrap. The width of the intrinsic size of the text view will be set so that it fills the width and the intrinsic height will be set to fit the whole text.
I previously thought it was about drawing the bubbles, so I first gave this answer:
If you look at Messages.app, you'll see that they're not circular bubbles. They are basically composed of several shapes overlaid on each other. A rectangle with rounded corners, plus a bezier path of the tip.
So you should be able to take a NSTextView for the text, make it a subview of a custom view that draws a rounded rectangle and the tip in its drawRect method, and then use auto layout constraints to make your bubble view resize with the text view and the text view to the window width.
You could probably also have the bubble view host a CALayer with fill and rounded corners, plus one with an image for the tip (or aCAShapeLayer for the tip), but drawRect is the easier approach.

NSTextField and Auto Layout in NSTableView

I've got a view-based NSTableView. I'm trying to understand the problem of why I cannot position / resize the NSTextField that resides in the NSTableCellView. I believe this problem is related to the intrinsic content size. Therefore I modified the Content Hugging and Compression Resistance to prioritise hugging. Please see screenshots of IB and the results when running the app.
Purple rectangle is the Custom View.

NSOutlineView in NSPopover not readable in OSX 10.10 Yosemite

I have a NSPopover containing a NSOutlineView (source list) that is displayed over a usually dark background (but it's not always dark). The NSOutlineView has a transparent background to blend nicely with the NSPopover view. This looked great in OS X 10.9 but in 10.10 the system changes the text color in the NSOutlineView based on the background. The result is that the text becomes completely gray and unreadable in some cases:
If I change the popover to be HUD style it is more readable:
However, in this case, it becomes problematic with lighter backgrounds (the top).
Is there any way to control the text color in the NSOutlineView so that the color stays the same no matter the background? I have tried setting the color of the text cell to black instead of the system colors but it does not help.
Also, can I control/remove the transparency of the NSPopover? I have read that NSPopover makes use of NSVisualEffectView, which has some appearance controls, but I don't know how to access it from NSPopover.
For aesthetic reasons I do not want to put the NSOutlineView under a solid background view. In this case there will be a ugly mismatch in color between the popover background and its arrow.
EDIT:
I was able to remove the transparency using the following code:
NSView *popoverView = popover.contentViewController.view.superview;
popoverView.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
It works but feels like a ugly hack. I welcome better suggestions.
EDIT2:
This is what it looks like with the aqua style. No transparency and black text.
Set the mode to something different other than source list and you should get the pre-10.10 style, i.e. without the translucency.

Resize NSTableView or NSScrollView depending on number of rows in table

I have a view-based NSTableView which is embedded in an NSScrollView. It has custom cells that are x number of pixels high. The NSScrollView is the same size as the panel that it is a subview of. I want to resize the entire NSTableView depending on how many rows are in the table.
Everything is working except the resizing. Resizing the scroll view manually in IB seems to have the desired affect, but NSSrollView does not seem to have a class method to resize its view (like NSView has setFrame). Should I be resizing the scollview, the tableview, both, or something else? Does NSScrollView have a setFrame method or similar that I am missing?
Thanks.
Before you try to do it programmatically, make sure you have the outline view's autosizing masks set up properly in the nib file. It sounds like you simply want the outline view (and its scroll view) to always remain the same size as the window that it's inside.
By default, the autosizing masks of an NSScrollView/NSOutlineView combo that you place into a window looks like the following:
In other words, it's set up to always remain the same size as it is now, no matter how large you resize the window to be.
What you want to do is to change the autosizing masks to look like in the image below:
To do that, you click in the white autosizing box wherever there's a dotted red line to toggle it into a solid red line. Once it's configured that way, the scroll view (and table view) will always (automatically) be resized to be the same size as the window that it's in.
There may also be a way to achieve this using Lion's new "auto layout" feature, but I'll have to leave that to someone who has more experience with it.
In case you really need to do this (such as when you want all rows to fit in the scrollview alleviating the need to scroll) and the scroll view is only a portion of the window/view you can do:
[[myTableView enclosingScrollView] setFrame:newFrameRect];
scrollview.frame = CGRrectMake(x, y, w, h);

How can I add shiny surface to UITableView

How can I add shiny surface to UITableView
This is done easily. From the screenshot you supplied it appears that most of what you're pointing out is photoshopped images positioned with UI elements supplied from within Xcode and customized via code.
The tableView for example appears to be on a Grouped Table View laying on top of a photoshopped textured image. The tableView itself has a custom color to all the cells and a custom color and shadow to the cell separators. You can use Google to see how to customize a UITableView pretty easily.
But like said, most of this is from the magic of Photoshop.
Create your own views and photoshop them.