10.10 Source List that goes through TitleBar? - objective-c

Just curious about how to accomplish this kind of custom columned app view. The source list goes straight through the titlebar but just on one side, I'm guessing that they hid the titlebar, maybe and then used an NSVisualEffectView? Any source code or tips are appreciated, its a pretty cool and from what I am seeing fairly widely used UI Element for Yosemite Apps.
The Search Bar in this photo and the Add List button are obviously in different views and I totally understand that an NSOutlineView with a SourceList style will automatically create this kind of effect in 10.10 but the button and the search field can't be in the source list scroll area yet their background is consistent with that of the source list which makes me think this effect is more view based than source list based.

Ok, so I answered this myself. I created a github repository here to show others how to easily create the effect that I was looking to create.
Tri-Transarent-Window
The basic gist is to create a NSVisualEffectsView and then simply hide the titlebar and set the titlebar mask.
#implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
self.window.styleMask = self.window.styleMask | NSFullSizeContentViewWindowMask;
self.window.titleVisibility = NSWindowTitleHidden;
self.window.titlebarAppearsTransparent = YES;
}
The above code will make the window accept the view and it will auto bleed through the titlebar. Here is my XIB
When you run you get a nice sidebar style transparent view that extends through the titlebar.

Related

iOS7 - content overlapping during push segue from table view

Apologies if this has been asked before. I can't find any reference to this particular problem though.
I have an app which is basically a table view nested within a navigation controller. Each item from the table segues to a fresh view (via a generic push transition), containing some content within a scrollview. I have set this all up using storyboard for ease of layout.
When you click an item in the table, the intention is for the table to slide off the screen to the left and be replaced by the content view. This works fine in iOS 6, but since testing the app on iOS 7 I've noticed the functionality is different.
In iOS 7 the content view slides into frame as normal, but the table view only slides a little way to the left - still visible behind my new content. It disappears very suddenly after half a second or so, but the effect is very jarring as it creates a momentary overlap of two views.
This is only a problem because my content views have transparent backgrounds, but this is important to maintain for the effect I want. So just to be clear, my content view slides in over the top of the menu, which subsequently disappears. Looks very odd.
Any help on this would be much appreciated. I'd be curious to know the reason for this change and if there's a way I can fix it. Preferably by making the menu slide all the way offscreen again.
Thanks!
I had the same problem.
Try to add into target ViewController (that shows up after push)
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.backgroundColor = [UIColor redColor];
}
If all is ok you can change background to something like that
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"GreenBkg.png"]];
ps. tableView needs to be defined as #property in your .h filw

Making Another Screen in Xcode (iOS)

I'm developing my first app using the latest version of Xcode and the iOS SDK. I'm seeing a number of options, and quick Googling has failed me so far. I have one main screen set up for my app so far (it features a search text field which displays content in another text field), and I'd like to now make a second screen. I can do this in a number of ways, like have a switch where the text field changes to a picker control and such an action changes the behaviour, OR I can just switch to another view entirely. I figure learning the second method will be more beneficial to me in the future, so I'm wondering what I should make to do that. A View? Another storyboard?
Add a view ; a view is equivalent to a page.
Storyboard is a collection of views/pages ; it helps keep views together, & then you can also organize your flows between views/pages 'within' the storyboard easily. Storyboard is like a Java/C++ package, whereas View is like a Class.
You have to add another UIViewController subclass and the XIB, and then #import it and then open it.
[self presentViewController:viewController animated:YES completion:nil];

UIBarButtonItem created in Interface Builder not working - confused

I am trying to tidy up my UI by consolidating various things in a Tool Bar, and am utterly confused. I am using Interface Builder rather than constructing the controls programmatically, because my UI is fairly simple and not particularly dynamic.
What I did did so far:
Added an empty tool bar.
Dragged two previously existing and working buttons onto the tool bar. They changed their class from UIButton
to UIBarButtonItem, and the inspector now shows them as having no
Sent Actions or Referencing Outlet, but the the previous action &
outlet in the View Controller - responding to taps, setting the
label of the button - still work.
Created a new Button directly
in the tool bar. Wired up its action & outlet by ctrl-drag in the
normal way. The inspector shows the Action and Outlet for this
button as connected, which is nice, but sadly neither of them works.
Clicking the button does not invoke the action; setting the label of
the button does not cause anything to happen on the screen, even
after I tried prodding the tool bar with a setNeedsDisplay.
I'm not sure what to try next. Googling has shown me that I'm not the only person to find using UIToolBar via Interface Bulder difficult and confusing, but I haven't found a solution to my exact problem.
I don't particularly want to resort to creating my entire GUI programmatically just to tidy up a few buttons. Creating all the controls in Interface Builder outside the tool bar, getting them wired up and working, then moving them into the tool bar would presumably also work - but it would be a kludge, and would leave me still none the wiser if anything went wrong later.
Should you try using UIBarButtonItem instead of UIButton? It works for me.
i had a similar issue.
Did you created an extra UITapGestureRecognizer for root view ?
Maybe for something like > When elsewhere than UITextView clicked, resignFirstResponder for all UITextViews !
In my case, on 7.1, that extra UITapGestureRecognizer prevented transfer of event to IBAction of UIBarButtonItem which is inside an UIToolBar.
IBAction was made on Storyboard by Ctrl+Drag.
on 8.1 it was working. Not on 7.1
Read some suggestions to create an extra UIView and putting all visual elements into that extra UIView except UIToolBar

How do I make an action in one view close itself and open another view?

New to obj-c and cocoa, working a on a simple game as my first (mac os x) app. I have a menu view and a game view:
MenuView.h/m
MenuViewController.h/m
GameView.h/m
GameViewController.h/m
I want the menu to be displayed by default, and when the play button (which is in the MenuView) is clicked I want the menu to go away and the game to appear. I understand actions and outlets, but I don't know where to start on making the views swap themselves out. Any help? It seems like I would need to somehow make my MenuViewController talk to my MainController?
Peter Hosey,
If you are looking at the MenuViewController as a sort of "main" view controller, at the moment the play button is clicked, you could initialize an instance of GameViewController:
- (IBAction)gameButtonClicked {
GameViewController *game = [[GameViewController alloc] init];
// we put the game view as the MenuViewController's view
[self setView:game.view];
[game release];
}
Of course, you need to import the "GameViewController.h" to access it.
If you want them in the same window and at the same size, you can put both views into a tabless tab view. Just switch the tab to switch which view is visible.
Another way would be to put them in different windows and use a window controller rather than a view controller for each one. Among other things, this makes it easy to make the game window user-resizable without disturbing the size of the menu window.
Since you want your MenuViewController to be what calls and takes care of GameViewController, I'd suggest something similar to what Rafael said. Try putting an instance of GameViewController in your Interface Builder file, but making it hidden. When they press the "Play" button to activate the game, simply send the GameViewController to the front and make it visible. It's a bit clumsy, but it works. Remember to hide all the buttons and interactions regarding your menu though. You don't want to accidentally activate the high scores list when playing a game!
Also, I'd recommend looking into Utility applications. (They're one of the template types you're given when you create a new project.) They're built to switch between two seperate view controllers, and it might just be what you're looking for.

Looking for info on custom drawing of interface components (Cocoa)

It seems like more and more OS X apps these days are doing all kinds of fancy drawing stuff for custom controls. Apps like Twitterific, Things, EventBox, Versions just to name a few....
So basically I'm looking for any information on how to get started doing this kind of thing. Not sure if it is just done by subclassing controls and using custom drawing or if it is something entirely different.
Any help is greatly appreciated. THanks!
It depends entirely on what you want to do.
The "Show Raw Properties" button in Versions for instance is an NSButton subclass, because basically what we needed is standard button behavior with our own look.  One way to subclass a button is to simply implement your own -drawRect:(NSRect)rect method in the NSButton subclass, but we decided to stick with the way NSButton is implemented in Cocoa, meaning most drawing is done by the button's cell, so the implementation looks like this:
In the NSButton subclass:
+ (Class) cellClass
{
return [OurButtonCell class];
}
- (void)drawRect:(NSRect)rect
{
// first get the cell to draw inside our bounds
// then draw a focus ring if that's appropriate
}
In the NSButtonCell subclass (OurButtonCell):
- (void)drawInteriorWithFrame: (NSRect) rect inView: (NSView *) controlView
{
// a bunch of drawing code
}
The Timeline view in Versions is actually a WebView, the page that you see in it uses javascript to collapse headers you click on.
The rule of thumb I use for where to start out with a custom control is:
To customize the look of a standard Cocoa control:
subclass the appropriate control (like e.g. NSButton and NSButtonCell)
stick as close as makes sense to the way the default control is implemented (e.g. in a buttoncell, start from the existing attributedTitle instance method to draw the button title, unless you always want to draw with the same attributes regardless of what's set up in IB or if you need to draw with different attributes based on state, such as with the trial expiration button in Versions' main window)
Creating an entirely new UI element:
subclass NSView and implement pretty much all mouse and key event handling (within the view, no need to redo "hitTest:") and drawing code yourself.
To present something that's complex, of arbitrary height, but isn't a table:
See if you can do it in HTML, CSS and JS and present it in a WebView.  The web is great at laying out text, so if you can offload that responsibility to your WebView, that can be a huge savings in pain in the neck.
Recommended reading on learning how to draw stuff in your own custom view's drawing methods: Cocoa Drawing Guide
Customizing the look of for instance an NSTableView is an entirely other cup of tea, thanks to the complexity of a tableview, that can happen all over the place.  You'll be implementing your own custom cells for some things you want to do in a table, but will have to change the way rows are highlighted in a subclass of the actual NSTableView object itself.  See for instance the source code for iTableView on Matt Gemmell's site for a clear example of where to draw what.
Finally, I think Abizer's suggestion to go check out the code of BWToolkit is a great idea.  It might be a bit overwhelming at first, but if you can read and understand that code you'll have no trouble implementing your own custom views and controls.
Have a look at some excellent example code: BWToolkit