TwUI is a hardware accelerated UI framework for Mac, inspired by UIKit. It enables:
- GPU accelerated rendering backed by CoreAnimation
- Simple model/view/controller development familiar to iOS developers
It differs from UIKit in a few ways:
- Simplified table view cells
- Block-based layout and drawRect
- A consistent coordinate system (bottom left origin)
- Sub-pixel text rendering
We're currently using TwUI to build Firehose. As we fix bugs and make improvements we will list them here. If you have a fix or improvement that you'd like to contribute, please open a pull request and we'll merge it in.
Fixed:
- (05/09/13) TUITextView: now calls super in drawRect. Multiple draws was making the text look thicker and thicker.
- (05/09/13) TUIStretchableImage: capInsets are now scaled based on retina/non-retina.
- (05/10/13) TUIStretchableImage: variable names were wrong, referring to the wrong image slices.
- (05/10/13) TUIButton: If a button is disabled, it no longer highlights the title on hover.
- (05/11/13) TUIStretchableImage: fixed so that 9-slice images display correctly on retina displays.
- (05/15/13) TUITableView: Making the table view clip subviews by default
- (05/15/13) TUIRefreshControl: got rid of dismiss animation until it can be done correctly.
- (05/15/13) TUIView: making it so that
TUIView
block based draw rect will call it's own draw rect first, then the block. - (05/20/13) TUIButton: making the image view
userInteractionEnabled
NO by default so it doesn't interfere with clicking the button. - (05/21/13) TUITextView: can paste URLs. michaelvillar
- (05/22/13) TUIView:
+new
calls the designated initializerinitWithFrame
- (06/03/13) TUITextField: when a text field was secure, no caret would show up. Fixed that.
- (06/03/13) TUIView: turned off subpixel rendering by default. makes text look ugly.
- (06/13/13) TUIButton: image for selected state won't go back to normal state on hover.
- (06/25/13) TUIView+Event: pulled in fixes from michaelvillar branch.
- (06/29/13) TUITableView: Added reentrancy guard to table view so if you can reloadData and reloadLayout in succession it won't cause a race condition.
- (07/20/13) TUITextRenderer: Fixes to emacs key binding behavior in text fields/views.
Added
- (05/11/13) TUITextView: added
lineSpacing
property. - (05/11/13) TUITextField: added
textFieldShouldTabToPrevious
delegate method. - (05/11/13) TUIRefreshControl: pulled in
TUIRefreshControl
from githubs branch. (from github.com/galaxas0 & github.com/Sephiroth87) - (05/15/13) TUIRefreshControl: added
arrowColor
property. - (05/15/13) TUIButton: added
TUIButtonTypePush
to make aTUIButton
that kinda looks like default AppKit button. - (05/15/13) TUIButton: added
setBackgroundColor:forState:
- (05/16/13) TUIPopover: added
becomesKeyWindow
as well asbecomeKeyWindow
. This is good if you're using the popover as search autosuggest. - (05/18/13) TUITextField: added
+ (void)setClearButtonImage:(NSImage *)clearButtonImage
- (05/31/13) TUIButton: add
keyEquivalent
- (06/01/13) NSColor+RGBHex: added category on
NSColor
for creating colors from Hex values. - (06/01/13) TUIView: adding
nextKeyView
toTUIView
as well as implied tabbing toTUITextField
. - (06/01/13) TUIResponder: added
addAction:forControlEvents:
that just sends the action up the responder chain. This is good for views with controllers. - (06/01/13) TUITextView/Field: added
secure
property. - (06/14/13) TUIView: added
description
andrecursiveDescription
- (06/25/13) MTAnimation: added
MTAnimation
as a submodule so that it's available across the framework and any project that includes it. This is a good thing. - (06/25/13) TUIView: added frame convenience accessors. easily change frame values right on the view: e.g.
view.x = 3; view.height = 20
- (06/25/13) TUITableView: added insertion/deletion cell updates. this is huge
- (06/29/13) TUITextField/TUITextView: added undo to all text editor views.
- (07/03/13) TUIControl/TUIButton: adding loading state to controls. added a spinner to buttons in loading state.
- (08/01/13) TUITableView: added a completion block to table view cell animations.
- (08/21/13) TUIAdvancedTextView: a new text view that has all the right emacs key bindings and behaves exactly like a proper NSTextView.
- (08/24/13) TUITableView: added
reloadDataAndMaintainSelection
- (08/24/13) TUIAdvancedTextView: added methods for inserting text at the end of the contents or at the very bottom.
Add
pod 'TwUI', git: "https://github.com/mysterioustrousers/twui"
to your Podfile.
Your TUIView
-based view hierarchy is hosted inside an TUINSView
, which is the bridge between AppKit and TwUI. You may set a TUINSView
as the content view of your window, if you'd like to build your whole UI with TwUI. Or you may opt to have a few smaller TUINSViews
, using TwUI just where it makes sense and continue to use AppKit everywhere else.
You can also add NSViews
to a TwUI hierarchy using TUIViewNSViewContainer
, which bridges back into AppKit from TwUI.
An included example project shows off the basic construction of a pure TwUI-based app. A TUINSView
is added as the content view of the window, and some TUIView
-based views are hosted in that. Within the table view cells, some NSTextFields
are also added using TUIViewNSViewContainer
. It includes a table view and a tab bar (which is a good example of how you might build your own custom controls).
TwUI is currently shipping in Twitter for Mac and GitHub for Mac, in use 24/7 by many, many users, and has proven itself very stable.
This project follows the SemVer standard. The API may change in backwards-incompatible ways between major releases.
The goal of TwUI is to build a high-quality UI framework designed specifically for the Mac. Much inspiration comes from UIKit, but diverging to try new things (i.e. block-based layout and drawRect), and optimizing for Mac-specific interactions is encouraged.
TwUI has a mailing list, subscribe by sending an email to twui@librelist.com.
Copyright 2011 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.