nsomar / OAStackView

Porting UIStackView to iOS 7+
MIT License
2.14k stars 200 forks source link

OAStackViewProxy #87

Closed joemasilotti closed 8 years ago

joemasilotti commented 8 years ago

This PR enables developers to use a single API when dealing with stack views. OAStackViewProxy wraps a UIStackView on iOS 9 and an OAStackVew on any older OS version.

Each method call takes advantage of Swift's build in #avaiable API to determine which stack view to use under the hood. Each property is exposed on the proxy with OAStackView's enum types. The proxy also takes advantage of Swift's didSet to update properties on the stack views.

I updated the example app to use the proxy over an OAStackView directly. This means we don't have to modify the tests because we are already using the class. However, this is only the case on iOS 8. Running the tests on iOS 9 will just use a wrapped UIStackView.

One caveat to this approach is that the target application needs to import <OAStackView/OAStackView-Swift.h> to use the proxy. I also had to enable CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to successfully build the module. Perhaps someone with more experience in building frameworks can lend a hand here.

Note: Storyboards are not supported.

This PR was inspired by @natanrolnik's work on #32.

nsomar commented 8 years ago

Hey super cool PR thanks. 👍

nikolaykasyanov commented 7 years ago

Wouldn't this compromise iOS 7 compatibility? I mean, CocoaPods requires frameworks and hence iOS 8+ deployment target for dependencies with Swift code.