controls in notification center today widget have their colours inverted - swift

I'm building an app extension for the Today section of the Notification Centre in OSX. My problem is that when I add controls like NSTableView or NSDatePicker their colours get inverted. NSTextField and NSButton seem to get inverted to, but they look great when they do. However, NSTableView does not look good, and I'd like it to display like it does in a normal window.
I don't have enough reputation to post an image apparently, so you'll have to checkout this screenshot to see what I mean.
I've tired fixing this programmatically in swift by setting the NSTableView's appearence property but that doesn't seem to fix my problem.
tableView.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
Does anybody know how to fix this?

Related

Some Border Types in NSImageView Not Appearing

I've looked in previous posts in SO and elsewhere for an answer but no luck. I'm putting images in an NSCollectionView as well as just a single image itself but the only border that seems to work is the grey Bezel border. Other types that are available don't show up, like Button or Groove. This is true no matter what scaling option I use, or even if I use it in code. I'm using NSImageView.imageFrameStyle.
I hope someone has some insight into this. I didn't provide any code since I didn't think that's necessary. Using Xcode 10.1, Swift 4.2. Thanks for any help.

Rounded corners on an NSTextView/NSScrollView?

There is a similar question already on here but it is in objective C. The answer in objective C is apparently:
[self.textView.layer setCornerRadius:10.0f];
I've tried translating this into Swift a few different ways. I'm guessing I want something like this (or maybe there is now a completely different way of doing it given that the obj-c question was posted way back in 2012):
consoleTextView.layer.setCornerRadius(10)
I can't see an option for it in the attributes inspector on xcode either. Maybe it's the NSScrollView that needs changing, I don't know. Hopefully someone with more experience in swift/xcode can help me out.
EDIT- As requested, how the consoleTextView is created:
consoleTextView = consoleScrollView.documentView as? NSTextView
EDIT- Picture of scroll/textView, it's the grey box at the bottom. It's used as a terminal-like window.
I managed to solve my problem:
consoleScrollView.wantsLayer = true
consoleScrollView.layer?.cornerRadius = 10
That works ^
You could also do the same with the TextView but you will be left with the square outline of the ScrollView behind it, so if you're trying to achieve the same thing as me you'll have to do it with the ScrollView as well anyway.

Text field overlay with back-drop like Clear iPhone app

I've been playing around with JTGestureBasedTableView, but this library only deals with pulling and swiping gesture handling.
I am trying to figure out how the overlay text field input (with translucent background) is implemented in Clear iPhone app (screenshot below). This is the point when you pull down a new cell and it turns into a text field, and once you finish typing in, the content gets filled into the top-most cell, which is presumably hidden behind the textfield.
What is the simplest way to do this?
Here is an excellent tutorial on clear app by Colin Eberhardt .It explains well how the implementation is done

How can I prevent Xcode from changing the color of my buttons?

So I've done a button for my iPad app, and I saw something strange. When I run my app in the iOS 5 simulator, it changes the color, and the lines of my button become discontinuous. But when I push it, the button comes back to the right color, and the lines are ok. I think it's something that Xcode does automatically with any button, and I don't find the way to cancel it. Thank you for helping!
PS: The button code is so simple:
IBOutlet UIButton *button;
This is what it should look like:
And this is how it looks in the simulator:
Both tams and JacobFennell have good points, but you should also note that graphics are often represented much differently on the simulator than on a real device. You should try running your app on a device and see if the problem persists; I have had many 'problems' with custom buttons which turned out just to be improper rendering on the part of the simulator.
Since you are using the Interface builder, make sure that you are setting the button type to custom and that you have changed the behavior for all of the states. Under the dropdown menu of where you can set the type they also have StateConfig, where you can configure the look and text of your button for all of its different states: highlighted, default, disabled...Check that those settings are correct as well.
Hope this helps!
Tams
Your button frame size doesn't seem to match the size of your image. Your art should match the (button/view) frame size pixel for pixel, otherwise you may get blurry images and scaling representation artifacts.
Else, you can change the view content mode (UIViewContentMode) of the frame from UIViewContentModeScaleToFill to UIViewContentModeTopLeft

Text input box like the SMS app on the iPhone

I am having a terrible time trying to get an input box like the one in the SMS app.
Can anyone offer some guidance on how to build one of these and make it look good? I need an input box that is shaped nicely like the UITextfield but will stretch vertically when typing.
I assume that I need to calculate width of the text and stretch the overlay image frame vertically when the text word wraps. The closest I have come does stretch but the cursor bounces all around when nearing the boundaries.
UPDATE:
I have worked on this everyday for a week and I have about given up on the UITextView. I can get it to stretch properly but when backspacing, the Textview height shrinks too much when going up a line. As I continue backspacing it corrects itself. For example, it displays this behavior when I am on line 4 and backspace up to line 3. Then as I continue backspacing, it corrects until I get to the end of line 2. Then it corrects itself,.... etc.
I decided to try to subclass UITextField but I can't even get it to display in the Frame size that I specify. 150,150,150,150.
Try Chat Input Sample. It has the similar look and functionality of SMS app.
Three20 project has a control that should do this for you.
From the Three20 README:
TTTextEditor is a UITextView which can
grow in height automatically as you
type. I use this for entering messages
in Facebook Chat, and it behaves
similarly to the editor in Apple's SMS
app.
You get to do this yourself. Luckily, the UITextField can notify you whenever its text changes using UITextFieldTextDidChangeNotification, and luckily NSString has methods (under the UIKit Additions) that let you get the height of the string given a certain width using boundingRectWithSize:options:attributes:context:, and luckily you can resize a UITextField yourself using frame.
I know this is old but for the people that still look at this answer there is now a nice control from Slack that does that called SlackTextViewController.