AppKit: How can I remove one pixel inset of NSOutlineView - swift

I'm totally new to AppKit. I'm so confused about managing layout of AppKit views.
I have a view which frame is 450*300
and I added an outline view in the view but it has one pixel inset automatically added.
This makes a one pixel border and it makes me annoying.
I can't fix it at all. There's no options about insets, constraints and resizing frame. What I wanna do is just making outline view's size the same as the super view's size so that there's no tiny border.

Related

NSView equivalent of UIView Clip Subviews?

Is there a way to disable clipping of subviews of NSView? In UIView there is a “clip subviews checkbox” and the backing clipToBounds property, but I cant find anything similar in Cocoa.
Here is my scenario: I have this grey dot that you can drag on the screen:
When the user drags the dot I want to show up and down arrows that I have in the background. The up arrow is outside the bounds of the NSView holding the dot and arrow.
You could use the [NSView frameForAlignmentRect:] method. It defines the frame which is used for the constraints based layout. The actual frame can be much larger to allow displaying the arrows when the view is moved.
Cocoa is using this feature to compensate for shadows or other parts of views which do not "count" as actual frame of a control.
From the documentation:
The constraint-based layout system uses alignment rectangles to align views, rather than their frame. This allows custom views to be aligned based on the location of their content while still having a frame that encompasses any ornamentation they need to draw around their content, such as shadows or reflections.

UITableview clipsToBounds

I am creating an iPad view which has a tableview as a subview. The tableview only takes a small portion of the screen and is somewhere near the middle of the screen and it contains some menu items. I want people to be about to scroll this tableview up and down however I do not like how the cells disappear against a hard edge. When I set clipsToBounds to false, I get what I want in that the hard edge is not there anymore but the top/bottom cell disappears when the tableview needs that cell for recycling. Is there a common technique to avoid this hard-edge of when the cells scroll up against the tableview's bounds? I was thinking of adding gradient alpha masks on a parent container view but it seems a bit over the top.
There are no hard and fast rule about this, but you certainly can do whatever you feel best. What I would do in a case of floating tableView is giving it a nice border using layer. It is easy to code (2~3 lines). Round the edge to make it pretty.
If you want to drop shadow, it gets a little more complicated but possible. Just draw a bezier curve path of a rectangle (where you want your shadow to appear). Assign that CALayer shadowPath. Then add it to the table.
You can also gradient an alpha to make it appear shadow like.
But I would suggest, you set clipsToBounds to YES since it looks horrible otherwise, given the fact that the table 'floats' somewhere in your view.

UIImageView masks and bottom alignment

I am working on an app that has TableViewCells with varying heights. I am placing a UIImageView into them and each will use the same size image (the same size of the largest cell), however I need to mask the excess in the smaller cells (keeping the bottom, not the top).
To be more specific, I have 3 different cell heights, 112, 104 and 88. The images will all be 112 tall and I want the images to have the tops cut off on the smaller cells. Im pretty sure the answer lies within the bounds, frame and center attributes of a UIImageView, but I cant figure out exactly what I should be doing.
You will need to set the frame of your image view such that the bottom of the image view is aligned with the bottom of your cell.
You will also need to ensure the contentview of you cell is clipping content to its bounds (setClipToBounds to yes).
If I had to do this I would subclass the UITabelViewCell class and implement the layoutSubviews method. In your implementation don't forget to call super first so the content view has the right size (also if you go in editing mode). Then use the content view bounds and place your content accordingly.
When you add the image view to the cell, it should automatically cut off the top part, as long as you have the UIImageView bottom positioned within the frame, it should be what you wanted.

How do I set the right margin of a UITextView?

I have a vertically-scrolling UITextView that fills the width of the screen. I need the text view to have margins (contentInset) of 20 pixels on the left and the right. But for some reason, I can't get the right-hand margin to work, either in Interface Builder or in XCode.
The reason I can't just make the text view narrower is because I am adding a subview which needs to run the full width of the screen. Also, I can't turn subview clipping off, because it plays havoc with a load of other elements on the screen.
Anyone know why the contentInset property is not affecting the right margin?
Thanks!
You could add an intermediate view that can be the superview to your text view and what was previously it's subview.
New View with Frame(0,0,width,height)
->TextView with Frame(20,0,width-20,height)
->Subview with Frame(0,0,width,height)

iPhone SDK, selection Rectangle around a view

I have a Drawing app of sorts and am looking for some feedback on ways to draw a selection rectangle, and or the resize grips for a selected view.
So I have a custom class that is inherited from UIView, in it it contains a UIImageView, UILabel, and UIButton. I can have several on the screen at one time. I want to tap on one and draw a selection rectangle around it. From there if i drag I want the view and the selection rectangle to move with it. I would like the Selection Rectangle maybe 4px larger than the exiting bounds rect.
So my question is what is the best way to get the Selection Rectangle around the selected UIView object?
Do I offset the object so what when I add in the UIImageView, UILabel, and UIButton that are part of it I have a 4px buffer around the edges?
Do I adjust the View when selected to reposition the subview, increase the bounds and offset the frame?
Do I just create a new UIView that is 4px larger than the selected object and just move it with the selected view?
Do I just create a new UIView that is 4px larger than the selected object and and make the selected view a subview of it?
or? (your Idea Here...)
Thank you for your comments and Suggestions...
Scooter133
Consider setting the borderWidth property on your view's layer. Note that this is drawn within the view's bounds, so it may be more useful as a highlight state than a selection rectangle.