├── .DS_Store ├── .gitignore ├── LICENSE ├── README.md ├── TBBStockView.podspec ├── TBBStockView.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── TBBStockView ├── .DS_Store ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── .DS_Store │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── BtnView.h ├── BtnView.m ├── Info.plist ├── Masonry │ ├── .svn │ │ ├── entries │ │ ├── prop-base │ │ │ ├── MASCompositeConstraint.h.svn-base │ │ │ ├── MASCompositeConstraint.m.svn-base │ │ │ ├── MASConstraint+Private.h.svn-base │ │ │ ├── MASConstraint.h.svn-base │ │ │ ├── MASConstraint.m.svn-base │ │ │ ├── MASConstraintMaker.h.svn-base │ │ │ ├── MASConstraintMaker.m.svn-base │ │ │ ├── MASLayoutConstraint.h.svn-base │ │ │ ├── MASLayoutConstraint.m.svn-base │ │ │ ├── MASUtilities.h.svn-base │ │ │ ├── MASViewAttribute.h.svn-base │ │ │ ├── MASViewAttribute.m.svn-base │ │ │ ├── MASViewConstraint.h.svn-base │ │ │ ├── MASViewConstraint.m.svn-base │ │ │ ├── Masonry.h.svn-base │ │ │ ├── NSArray+MASAdditions.h.svn-base │ │ │ ├── NSArray+MASAdditions.m.svn-base │ │ │ ├── NSArray+MASShorthandAdditions.h.svn-base │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h.svn-base │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.m.svn-base │ │ │ ├── View+MASAdditions.h.svn-base │ │ │ ├── View+MASAdditions.m.svn-base │ │ │ ├── View+MASShorthandAdditions.h.svn-base │ │ │ ├── ViewController+MASAdditions.h.svn-base │ │ │ └── ViewController+MASAdditions.m.svn-base │ │ └── text-base │ │ │ ├── MASCompositeConstraint.h.svn-base │ │ │ ├── MASCompositeConstraint.m.svn-base │ │ │ ├── MASConstraint+Private.h.svn-base │ │ │ ├── MASConstraint.h.svn-base │ │ │ ├── MASConstraint.m.svn-base │ │ │ ├── MASConstraintMaker.h.svn-base │ │ │ ├── MASConstraintMaker.m.svn-base │ │ │ ├── MASLayoutConstraint.h.svn-base │ │ │ ├── MASLayoutConstraint.m.svn-base │ │ │ ├── MASUtilities.h.svn-base │ │ │ ├── MASViewAttribute.h.svn-base │ │ │ ├── MASViewAttribute.m.svn-base │ │ │ ├── MASViewConstraint.h.svn-base │ │ │ ├── MASViewConstraint.m.svn-base │ │ │ ├── Masonry.h.svn-base │ │ │ ├── NSArray+MASAdditions.h.svn-base │ │ │ ├── NSArray+MASAdditions.m.svn-base │ │ │ ├── NSArray+MASShorthandAdditions.h.svn-base │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.h.svn-base │ │ │ ├── NSLayoutConstraint+MASDebugAdditions.m.svn-base │ │ │ ├── View+MASAdditions.h.svn-base │ │ │ ├── View+MASAdditions.m.svn-base │ │ │ ├── View+MASShorthandAdditions.h.svn-base │ │ │ ├── ViewController+MASAdditions.h.svn-base │ │ │ └── ViewController+MASAdditions.m.svn-base │ ├── MASCompositeConstraint.h │ ├── MASCompositeConstraint.m │ ├── MASConstraint+Private.h │ ├── MASConstraint.h │ ├── MASConstraint.m │ ├── MASConstraintMaker.h │ ├── MASConstraintMaker.m │ ├── MASLayoutConstraint.h │ ├── MASLayoutConstraint.m │ ├── MASUtilities.h │ ├── MASViewAttribute.h │ ├── MASViewAttribute.m │ ├── MASViewConstraint.h │ ├── MASViewConstraint.m │ ├── Masonry.h │ ├── NSArray+MASAdditions.h │ ├── NSArray+MASAdditions.m │ ├── NSArray+MASShorthandAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.h │ ├── NSLayoutConstraint+MASDebugAdditions.m │ ├── View+MASAdditions.h │ ├── View+MASAdditions.m │ ├── View+MASShorthandAdditions.h │ ├── ViewController+MASAdditions.h │ └── ViewController+MASAdditions.m ├── Resource │ ├── .DS_Store │ └── images.bundle │ │ ├── dian_@2x.png │ │ └── dian_@3x.png ├── Source │ ├── .DS_Store │ ├── Common │ │ ├── .DS_Store │ │ ├── Common.h │ │ ├── CommonEnum.h │ │ ├── TBBStockView.h │ │ ├── UIColor+HL.h │ │ └── UIColor+HL.m │ ├── TBBKLine │ │ ├── .DS_Store │ │ ├── TBBKLineView.h │ │ └── TBBKLineView.m │ └── TBBTimeLine │ │ ├── .DS_Store │ │ ├── TBBTimeLineBottomView │ │ ├── TBBTimeLineBottom.h │ │ ├── TBBTimeLineBottom.m │ │ ├── TBBTimeLineBottomPointModel.h │ │ ├── TBBTimeLineBottomPointModel.m │ │ ├── TBBTimeLineBottomView.h │ │ └── TBBTimeLineBottomView.m │ │ ├── TBBTimeLineTopView │ │ ├── .DS_Store │ │ ├── TBBTimeLineTop.h │ │ ├── TBBTimeLineTop.m │ │ ├── TBBTimeLineTopModel.h │ │ ├── TBBTimeLineTopModel.m │ │ ├── TBBTimeLineTopPointModel.h │ │ ├── TBBTimeLineTopPointModel.m │ │ ├── TBBTimeLineTopTouchView.h │ │ ├── TBBTimeLineTopTouchView.m │ │ ├── TBBTimeLineTopView.h │ │ └── TBBTimeLineTopView.m │ │ ├── TBBTimeLineView.h │ │ └── TBBTimeLineView.m ├── TBBStockView.gif ├── ViewController.h ├── ViewController.m ├── data.plist └── main.m ├── TBBStockViewTests ├── Info.plist └── TBBStockViewTests.m └── TBBStockViewUITests ├── Info.plist └── TBBStockViewUITests.m /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 HLTangbinbin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TBBStockView 2 | iOS 股票走势图(分时图,K线图)--- 3 | 在绘制虚实线,走势图背景时使用了更简洁的方法----共同学习,欢迎提出宝贵的意见和更好的方法 4 | 5 | ![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat) 6 | ![CocoaPods](http://img.shields.io/cocoapods/v/TBBStockView.svg?style=flat) 7 | ![CocoaPods](http://img.shields.io/cocoapods/p/TBBStockView.svg?style=flat) 8 | ![Support](https://img.shields.io/badge/support-iOS8.0+-blue.svg?style=flat) 9 | 10 | 11 | 12 | ![image](/TBBStockView/TBBStockView.gif) 13 | 14 | 15 | 16 | Installation 17 | ============== 18 | 19 | ### CocoaPods 20 | 21 | 1. Add `pod "TBBStockView"` to your Podfile. 22 | 2. Run `pod install` or `pod update`. 23 | 3. Import \. 24 | 25 | 26 | ### Manually 27 | 28 | 1. Download all the files in the TBBStockView subdirectory. 29 | 2. Add the source files to your Xcode project. 30 | 3. Import `TBBStockView.h`. 31 | 32 | ### How to use 33 | 1. Import `TBBStockView.h`. 34 | ``` 35 | TBBTimeLineView *lineView = [[TBBTimeLineView alloc]initWithFrame:CGRectMake(0, 114.0f, KScreenWidth, 300.f) withDataArr:self.dataArr]; 36 | self.lineView = lineView; 37 | [self.view addSubview:self.lineView]; 38 | ``` 39 | 2. You should sure that the self.dataArr input must match the model,Specific please see the ViewController.m 40 | 41 | 42 | -------------------------------------------------------------------------------- /TBBStockView.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | s.name = "TBBStockView" 4 | s.version = "1.0.4" 5 | s.summary = "iOS股票证券走势图--分时图" 6 | 7 | s.description = <<-DESC 8 | * 分时图+K线图~完全用自己的思路封装的,绘制过程碰到一些坑 9 | * 网上很多第3方库使用的方法都一样,比如在绘制走势图封闭的背景颜色那一块 10 | 使用了更简单的思路 11 | *开源的很多,但是按照自己的思路完全写一遍收获更多 12 | DESC 13 | s.homepage = "https://github.com/HLTangbinbin" 14 | 15 | s.license = "MIT" 16 | 17 | s.author = { "HLTangbinbin" => "m18513848880@163.com" } 18 | s.ios.deployment_target = '8.0' 19 | s.source = { :git => "https://github.com/HLTangbinbin/TBBStockView.git", :tag => "#{s.version}" } 20 | 21 | s.source_files = 'TBBStockView/Source/**/*.{h,m}' 22 | s.resources = "TBBStockView/Resource/*.*" 23 | s.requires_arc = true 24 | 25 | s.dependency "Masonry" 26 | 27 | end 28 | -------------------------------------------------------------------------------- /TBBStockView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /TBBStockView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/7/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /TBBStockView/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/7/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /TBBStockView/Assets.xcassets/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Assets.xcassets/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /TBBStockView/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /TBBStockView/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /TBBStockView/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /TBBStockView/BtnView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BtnView.h 3 | // SelectedBtn 4 | // 5 | // Created by 唐彬彬 on 2017/3/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | typedef void (^addSubViewBlock)(NSInteger tag); 11 | @interface BtnView : UIView 12 | @property (nonatomic ,copy) addSubViewBlock myBlock; 13 | -(instancetype)initWithFrame:(CGRect)frame titleArray:(NSArray *)titleArray selectedColor:(UIColor *)selectedColor normalColor:(UIColor *)normalColor titleSize:(CGSize *)size; 14 | -(void)addSubviewWithBlock:(addSubViewBlock)block; 15 | @end 16 | -------------------------------------------------------------------------------- /TBBStockView/BtnView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BtnView.m 3 | // SelectedBtn 4 | // 5 | // Created by 唐彬彬 on 2017/3/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "BtnView.h" 10 | #import "Masonry.h" 11 | #import "UIColor+HL.h" 12 | #define KScreenWidth [UIScreen mainScreen].bounds.size.width 13 | #define KBtnHeight 44.0f 14 | #define KSlideHeight 2.0f 15 | #define WEAKINSTANCE(weakInstance,instance) __weak typeof(instance) weakInstance = instance; 16 | #define WS(weakSelf) WEAKINSTANCE(weakSelf,self) 17 | 18 | @interface BtnView () 19 | @property (nonatomic ,strong) UIButton *selectedBtn;//按钮 20 | @property (nonatomic ,strong) UIView *slideView;//滑块 21 | @property (nonatomic ,assign) NSInteger index; 22 | @property (nonatomic ,strong) NSArray *btnArray; 23 | 24 | @end 25 | 26 | @implementation BtnView 27 | 28 | -(instancetype)initWithFrame:(CGRect)frame titleArray:(NSArray *)titleArray selectedColor:(UIColor *)selectedColor normalColor:(UIColor *)normalColor titleSize:(CGSize *)size{ 29 | 30 | if (self = [super initWithFrame:frame]) { 31 | WS(ws); 32 | NSMutableArray *btnArr = [NSMutableArray array]; 33 | self.backgroundColor = [UIColor colorWithHexString:@"E0E0E0"]; 34 | for (int i=0; i 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 17313 5 | svn://tangbinbin@172.16.130.188/zzhl/%E9%A1%B9%E7%9B%AE/%E5%A4%A7%E4%BC%97%E5%B8%82%E5%9C%BA/05%E4%BB%A3%E7%A0%81/branch/app/iOS/Web2Native/zzhl/Classes/others/Lib/Masonry 6 | svn://tangbinbin@172.16.130.188/zzhl 7 | 8 | 9 | 10 | 2016-04-20T09:09:54.633160Z 11 | 2976 12 | chenzhongbao 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 1c1a7cb5-92e3-4f06-bba5-e8474a576c79 28 | 29 | ViewController+MASAdditions.h 30 | file 31 | 32 | 33 | 34 | 35 | 2016-10-13T00:54:41.000000Z 36 | 1d5740a8aabe636e53c12ab79a86a090 37 | 2016-04-20T09:09:54.633160Z 38 | 2976 39 | chenzhongbao 40 | has-props 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 556 62 | 63 | View+MASAdditions.m 64 | file 65 | 66 | 67 | 68 | 69 | 2016-10-13T00:54:41.000000Z 70 | bebf32d2475c3f617ff03e6336411302 71 | 2016-04-20T09:09:54.633160Z 72 | 2976 73 | chenzhongbao 74 | has-props 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 5065 96 | 97 | MASConstraint.m 98 | file 99 | 100 | 101 | 102 | 103 | 2016-10-13T00:54:41.000000Z 104 | 70401ecd03feb971831be4414f4fc706 105 | 2016-04-20T09:09:54.633160Z 106 | 2976 107 | chenzhongbao 108 | has-props 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 7546 130 | 131 | NSArray+MASAdditions.h 132 | file 133 | 134 | 135 | 136 | 137 | 2016-10-13T00:54:41.000000Z 138 | 36caa697d9a72a5b800157f6d1c02fe5 139 | 2016-04-20T09:09:54.633160Z 140 | 2976 141 | chenzhongbao 142 | has-props 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 1682 164 | 165 | MASConstraint+Private.h 166 | file 167 | 168 | 169 | 170 | 171 | 2016-10-13T00:54:41.000000Z 172 | c54eb3d27fbc83387fa153eaba990448 173 | 2016-04-20T09:09:54.633160Z 174 | 2976 175 | chenzhongbao 176 | has-props 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 1785 198 | 199 | ViewController+MASAdditions.m 200 | file 201 | 202 | 203 | 204 | 205 | 2016-10-13T00:54:41.000000Z 206 | 90cb45c9c7df50e60ae465c6da566ee3 207 | 2016-04-20T09:09:54.633160Z 208 | 2976 209 | chenzhongbao 210 | has-props 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 588 232 | 233 | MASViewAttribute.h 234 | file 235 | 236 | 237 | 238 | 239 | 2016-10-13T00:54:41.000000Z 240 | 1e902bbef26cf5421917f65f31a01e73 241 | 2016-04-20T09:09:54.633160Z 242 | 2976 243 | chenzhongbao 244 | has-props 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 1217 266 | 267 | NSArray+MASAdditions.m 268 | file 269 | 270 | 271 | 272 | 273 | 2016-10-13T00:54:41.000000Z 274 | 8db6537325c2caa928e2be6b7f47fbb7 275 | 2016-04-20T09:09:54.633160Z 276 | 2976 277 | chenzhongbao 278 | has-props 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 1339 300 | 301 | View+MASShorthandAdditions.h 302 | file 303 | 304 | 305 | 306 | 307 | 2016-10-13T00:54:41.000000Z 308 | 94a9b4cf693487932a986f18df5cc3cf 309 | 2016-04-20T09:09:54.633160Z 310 | 2976 311 | chenzhongbao 312 | has-props 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 3240 334 | 335 | MASViewAttribute.m 336 | file 337 | 338 | 339 | 340 | 341 | 2016-10-13T00:54:41.000000Z 342 | 8eeb9762cbb06d4334bee396094215ab 343 | 2016-04-20T09:09:54.633160Z 344 | 2976 345 | chenzhongbao 346 | has-props 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 1191 368 | 369 | NSLayoutConstraint+MASDebugAdditions.h 370 | file 371 | 372 | 373 | 374 | 375 | 2016-10-13T00:54:41.000000Z 376 | d99120361688fdbab1f1f75908746301 377 | 2016-04-20T09:09:54.633160Z 378 | 2976 379 | chenzhongbao 380 | has-props 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 326 402 | 403 | NSArray+MASShorthandAdditions.h 404 | file 405 | 406 | 407 | 408 | 409 | 2016-10-13T00:54:41.000000Z 410 | 2ca614153c2343fa4af7b42da195ead8 411 | 2016-04-20T09:09:54.633160Z 412 | 2976 413 | chenzhongbao 414 | has-props 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 1016 436 | 437 | MASConstraintMaker.h 438 | file 439 | 440 | 441 | 442 | 443 | 2016-10-13T00:54:41.000000Z 444 | bf229de94c363cf372a60c137f8693b4 445 | 2016-04-20T09:09:54.633160Z 446 | 2976 447 | chenzhongbao 448 | has-props 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 5016 470 | 471 | MASCompositeConstraint.h 472 | file 473 | 474 | 475 | 476 | 477 | 2016-10-13T00:54:41.000000Z 478 | 0710d44254b8f02e421297c038f30413 479 | 2016-04-20T09:09:54.633160Z 480 | 2976 481 | chenzhongbao 482 | has-props 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 494 504 | 505 | NSLayoutConstraint+MASDebugAdditions.m 506 | file 507 | 508 | 509 | 510 | 511 | 2016-10-13T00:54:41.000000Z 512 | 5f9adf871f6a7ec5ca7fde301d854ece 513 | 2016-04-20T09:09:54.633160Z 514 | 2976 515 | chenzhongbao 516 | has-props 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 5455 538 | 539 | MASConstraintMaker.m 540 | file 541 | 542 | 543 | 544 | 545 | 2016-10-13T00:54:41.000000Z 546 | 3402a0a29e0254cae5f577d24610f888 547 | 2016-04-20T09:09:54.633160Z 548 | 2976 549 | chenzhongbao 550 | has-props 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 9270 572 | 573 | MASUtilities.h 574 | file 575 | 576 | 577 | 578 | 579 | 2016-10-13T00:54:41.000000Z 580 | edcb83bef0250fbdb6324090c253e165 581 | 2016-04-20T09:09:54.633160Z 582 | 2976 583 | chenzhongbao 584 | has-props 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 6059 606 | 607 | MASCompositeConstraint.m 608 | file 609 | 610 | 611 | 612 | 613 | 2016-10-13T00:54:41.000000Z 614 | e66f4330db46a60690d530f5d8f3c649 615 | 2016-04-20T09:09:54.633160Z 616 | 2976 617 | chenzhongbao 618 | has-props 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 4712 640 | 641 | MASViewConstraint.h 642 | file 643 | 644 | 645 | 646 | 647 | 2016-10-13T00:54:41.000000Z 648 | 0f01a381445307b6357e0fe4e6829ea0 649 | 2016-04-20T09:09:54.633160Z 650 | 2976 651 | chenzhongbao 652 | has-props 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 1275 674 | 675 | MASLayoutConstraint.h 676 | file 677 | 678 | 679 | 680 | 681 | 2016-10-13T00:54:41.000000Z 682 | b143394f1e487654446abc99e070c052 683 | 2016-04-20T09:09:54.633160Z 684 | 2976 685 | chenzhongbao 686 | has-props 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 505 708 | 709 | View+MASAdditions.h 710 | file 711 | 712 | 713 | 714 | 715 | 2016-10-13T00:54:41.000000Z 716 | 23ab8337fbd6d2f69c33ff1ff36799d5 717 | 2016-04-20T09:09:54.633160Z 718 | 2976 719 | chenzhongbao 720 | has-props 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 3775 742 | 743 | MASConstraint.h 744 | file 745 | 746 | 747 | 748 | 749 | 2016-10-13T00:54:41.000000Z 750 | 5fc87a6844aff2982c54d366f7af3f3a 751 | 2016-04-20T09:09:54.633160Z 752 | 2976 753 | chenzhongbao 754 | has-props 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 6979 776 | 777 | MASViewConstraint.m 778 | file 779 | 780 | 781 | 782 | 783 | 2016-10-13T00:54:41.000000Z 784 | a6efb9627849e21b2e5692dd525e3207 785 | 2016-04-20T09:09:54.633160Z 786 | 2976 787 | chenzhongbao 788 | has-props 789 | 790 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 13182 810 | 811 | MASLayoutConstraint.m 812 | file 813 | 814 | 815 | 816 | 817 | 2016-10-13T00:54:41.000000Z 818 | e08c00b0c0402fd5f1bc4fc902138e88 819 | 2016-04-20T09:09:54.633160Z 820 | 2976 821 | chenzhongbao 822 | has-props 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 | 840 | 841 | 842 | 843 | 227 844 | 845 | Masonry.h 846 | file 847 | 848 | 849 | 850 | 851 | 2016-10-13T00:54:41.000000Z 852 | 9923177757259b158a60f843ce9bdd6d 853 | 2016-04-20T09:09:54.633160Z 854 | 2976 855 | chenzhongbao 856 | has-props 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 802 878 | 879 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASCompositeConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASCompositeConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASConstraint+Private.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASConstraintMaker.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASConstraintMaker.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASLayoutConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASLayoutConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASUtilities.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASViewAttribute.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASViewAttribute.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASViewConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/MASViewConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/Masonry.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/NSArray+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/NSArray+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/NSArray+MASShorthandAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/NSLayoutConstraint+MASDebugAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/NSLayoutConstraint+MASDebugAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/View+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/View+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/View+MASShorthandAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/ViewController+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/prop-base/ViewController+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | K 14 2 | svn:executable 3 | V 1 4 | * 5 | END 6 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASCompositeConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASCompositeConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASConstraint+Private.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if TARGET_OS_IPHONE 131 | 132 | - (MASConstraint *)leftMargin; 133 | - (MASConstraint *)rightMargin; 134 | - (MASConstraint *)topMargin; 135 | - (MASConstraint *)bottomMargin; 136 | - (MASConstraint *)leadingMargin; 137 | - (MASConstraint *)trailingMargin; 138 | - (MASConstraint *)centerXWithinMargins; 139 | - (MASConstraint *)centerYWithinMargins; 140 | 141 | #endif 142 | 143 | 144 | /** 145 | * Sets the constraint debug name 146 | */ 147 | - (MASConstraint * (^)(id key))key; 148 | 149 | // NSLayoutConstraint constant Setters 150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 156 | */ 157 | - (void)setInsets:(MASEdgeInsets)insets; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 163 | */ 164 | - (void)setSizeOffset:(CGSize)sizeOffset; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 170 | */ 171 | - (void)setCenterOffset:(CGPoint)centerOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant 175 | */ 176 | - (void)setOffset:(CGFloat)offset; 177 | 178 | 179 | // NSLayoutConstraint Installation support 180 | 181 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 182 | /** 183 | * Whether or not to go through the animator proxy when modifying the constraint 184 | */ 185 | @property (nonatomic, copy, readonly) MASConstraint *animator; 186 | #endif 187 | 188 | /** 189 | * Activates an NSLayoutConstraint if it's supported by an OS. 190 | * Invokes install otherwise. 191 | */ 192 | - (void)activate; 193 | 194 | /** 195 | * Deactivates previously installed/activated NSLayoutConstraint. 196 | */ 197 | - (void)deactivate; 198 | 199 | /** 200 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 201 | */ 202 | - (void)install; 203 | 204 | /** 205 | * Removes previously installed NSLayoutConstraint 206 | */ 207 | - (void)uninstall; 208 | 209 | @end 210 | 211 | 212 | /** 213 | * Convenience auto-boxing macros for MASConstraint methods. 214 | * 215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 216 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 217 | */ 218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 221 | 222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 223 | 224 | 225 | #ifdef MAS_SHORTHAND_GLOBALS 226 | 227 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 230 | 231 | #define offset(...) mas_offset(__VA_ARGS__) 232 | 233 | #endif 234 | 235 | 236 | @interface MASConstraint (AutoboxingSupport) 237 | 238 | /** 239 | * Aliases to corresponding relation methods (for shorthand macros) 240 | * Also needed to aid autocompletion 241 | */ 242 | - (MASConstraint * (^)(id attr))mas_equalTo; 243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 245 | 246 | /** 247 | * A dummy method to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id offset))mas_offset; 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if TARGET_OS_IPHONE 212 | 213 | - (MASConstraint *)leftMargin { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 215 | } 216 | 217 | - (MASConstraint *)rightMargin { 218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 219 | } 220 | 221 | - (MASConstraint *)topMargin { 222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 223 | } 224 | 225 | - (MASConstraint *)bottomMargin { 226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 227 | } 228 | 229 | - (MASConstraint *)leadingMargin { 230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 231 | } 232 | 233 | - (MASConstraint *)trailingMargin { 234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 235 | } 236 | 237 | - (MASConstraint *)centerXWithinMargins { 238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 239 | } 240 | 241 | - (MASConstraint *)centerYWithinMargins { 242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 243 | } 244 | 245 | #endif 246 | 247 | #pragma mark - Abstract 248 | 249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 250 | 251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 252 | 253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 254 | 255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 256 | 257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 258 | 259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 260 | 261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 262 | 263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 264 | 265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 266 | 267 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 268 | 269 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 270 | 271 | #endif 272 | 273 | - (void)activate { MASMethodNotImplemented(); } 274 | 275 | - (void)deactivate { MASMethodNotImplemented(); } 276 | 277 | - (void)install { MASMethodNotImplemented(); } 278 | 279 | - (void)uninstall { MASMethodNotImplemented(); } 280 | 281 | @end 282 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASConstraintMaker.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASLayoutConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASLayoutConstraint.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASUtilities.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MAS_VIEW_CONTROLLER UIViewController 16 | #define MASEdgeInsets UIEdgeInsets 17 | 18 | typedef UILayoutPriority MASLayoutPriority; 19 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 23 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 24 | 25 | #elif TARGET_OS_MAC 26 | 27 | #import 28 | #define MAS_VIEW NSView 29 | #define MASEdgeInsets NSEdgeInsets 30 | 31 | typedef NSLayoutPriority MASLayoutPriority; 32 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 33 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 34 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 36 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 37 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 38 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 39 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 40 | 41 | #endif 42 | 43 | /** 44 | * Allows you to attach keys to objects matching the variable names passed. 45 | * 46 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 47 | * 48 | * is equivalent to: 49 | * 50 | * MASAttachKeys(view1, view2); 51 | */ 52 | #define MASAttachKeys(...) \ 53 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 54 | for (id key in keyPairs.allKeys) { \ 55 | id obj = keyPairs[key]; \ 56 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 57 | @"Cannot attach mas_key to %@", obj); \ 58 | [obj setMas_key:key]; \ 59 | } 60 | 61 | /** 62 | * Used to create object hashes 63 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 64 | */ 65 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 66 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 67 | 68 | /** 69 | * Given a scalar or struct value, wraps it in NSValue 70 | * Based on EXPObjectify: https://github.com/specta/expecta 71 | */ 72 | static inline id _MASBoxValue(const char *type, ...) { 73 | va_list v; 74 | va_start(v, type); 75 | id obj = nil; 76 | if (strcmp(type, @encode(id)) == 0) { 77 | id actual = va_arg(v, id); 78 | obj = actual; 79 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 80 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 81 | obj = [NSValue value:&actual withObjCType:type]; 82 | } else if (strcmp(type, @encode(CGSize)) == 0) { 83 | CGSize actual = (CGSize)va_arg(v, CGSize); 84 | obj = [NSValue value:&actual withObjCType:type]; 85 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 86 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 87 | obj = [NSValue value:&actual withObjCType:type]; 88 | } else if (strcmp(type, @encode(double)) == 0) { 89 | double actual = (double)va_arg(v, double); 90 | obj = [NSNumber numberWithDouble:actual]; 91 | } else if (strcmp(type, @encode(float)) == 0) { 92 | float actual = (float)va_arg(v, double); 93 | obj = [NSNumber numberWithFloat:actual]; 94 | } else if (strcmp(type, @encode(int)) == 0) { 95 | int actual = (int)va_arg(v, int); 96 | obj = [NSNumber numberWithInt:actual]; 97 | } else if (strcmp(type, @encode(long)) == 0) { 98 | long actual = (long)va_arg(v, long); 99 | obj = [NSNumber numberWithLong:actual]; 100 | } else if (strcmp(type, @encode(long long)) == 0) { 101 | long long actual = (long long)va_arg(v, long long); 102 | obj = [NSNumber numberWithLongLong:actual]; 103 | } else if (strcmp(type, @encode(short)) == 0) { 104 | short actual = (short)va_arg(v, int); 105 | obj = [NSNumber numberWithShort:actual]; 106 | } else if (strcmp(type, @encode(char)) == 0) { 107 | char actual = (char)va_arg(v, int); 108 | obj = [NSNumber numberWithChar:actual]; 109 | } else if (strcmp(type, @encode(bool)) == 0) { 110 | bool actual = (bool)va_arg(v, int); 111 | obj = [NSNumber numberWithBool:actual]; 112 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 113 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 114 | obj = [NSNumber numberWithUnsignedChar:actual]; 115 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 116 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 117 | obj = [NSNumber numberWithUnsignedInt:actual]; 118 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 119 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 120 | obj = [NSNumber numberWithUnsignedLong:actual]; 121 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 122 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 123 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 124 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 125 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 126 | obj = [NSNumber numberWithUnsignedShort:actual]; 127 | } 128 | va_end(v); 129 | return obj; 130 | } 131 | 132 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 133 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASViewAttribute.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASViewAttribute.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/MASViewConstraint.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/Masonry.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/NSArray+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | @interface NSArray (MASAdditions) 14 | 15 | /** 16 | * Creates a MASConstraintMaker with each view in the callee. 17 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 18 | * 19 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 20 | * 21 | * @return Array of created MASConstraints 22 | */ 23 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 24 | 25 | /** 26 | * Creates a MASConstraintMaker with each view in the callee. 27 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 28 | * If an existing constraint exists then it will be updated instead. 29 | * 30 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 31 | * 32 | * @return Array of created/updated MASConstraints 33 | */ 34 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | /** 37 | * Creates a MASConstraintMaker with each view in the callee. 38 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 39 | * All constraints previously installed for the views will be removed. 40 | * 41 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 42 | * 43 | * @return Array of created/updated MASConstraints 44 | */ 45 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/NSArray+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/NSArray+MASShorthandAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/NSLayoutConstraint+MASDebugAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/NSLayoutConstraint+MASDebugAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if TARGET_OS_IPHONE 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/View+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/View+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/View+MASShorthandAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/ViewController+MASAdditions.h.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILa 8youtGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/.svn/text-base/ViewController+MASAdditions.m.svn-base: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | 19 | - (MASViewAttribute *)mas_bottomLayoutGuide { 20 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 21 | } 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASCompositeConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | /** 13 | * A group of MASConstraint objects 14 | */ 15 | @interface MASCompositeConstraint : MASConstraint 16 | 17 | /** 18 | * Creates a composite with a predefined array of children 19 | * 20 | * @param children child MASConstraints 21 | * 22 | * @return a composite constraint 23 | */ 24 | - (id)initWithChildren:(NSArray *)children; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASCompositeConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASCompositeConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASCompositeConstraint.h" 10 | #import "MASConstraint+Private.h" 11 | 12 | @interface MASCompositeConstraint () 13 | 14 | @property (nonatomic, strong) id mas_key; 15 | @property (nonatomic, strong) NSMutableArray *childConstraints; 16 | 17 | @end 18 | 19 | @implementation MASCompositeConstraint 20 | 21 | - (id)initWithChildren:(NSArray *)children { 22 | self = [super init]; 23 | if (!self) return nil; 24 | 25 | _childConstraints = [children mutableCopy]; 26 | for (MASConstraint *constraint in _childConstraints) { 27 | constraint.delegate = self; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | #pragma mark - MASConstraintDelegate 34 | 35 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint { 36 | NSUInteger index = [self.childConstraints indexOfObject:constraint]; 37 | NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint); 38 | [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint]; 39 | } 40 | 41 | - (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 42 | id strongDelegate = self.delegate; 43 | MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 44 | newConstraint.delegate = self; 45 | [self.childConstraints addObject:newConstraint]; 46 | return newConstraint; 47 | } 48 | 49 | #pragma mark - NSLayoutConstraint multiplier proxies 50 | 51 | - (MASConstraint * (^)(CGFloat))multipliedBy { 52 | return ^id(CGFloat multiplier) { 53 | for (MASConstraint *constraint in self.childConstraints) { 54 | constraint.multipliedBy(multiplier); 55 | } 56 | return self; 57 | }; 58 | } 59 | 60 | - (MASConstraint * (^)(CGFloat))dividedBy { 61 | return ^id(CGFloat divider) { 62 | for (MASConstraint *constraint in self.childConstraints) { 63 | constraint.dividedBy(divider); 64 | } 65 | return self; 66 | }; 67 | } 68 | 69 | #pragma mark - MASLayoutPriority proxy 70 | 71 | - (MASConstraint * (^)(MASLayoutPriority))priority { 72 | return ^id(MASLayoutPriority priority) { 73 | for (MASConstraint *constraint in self.childConstraints) { 74 | constraint.priority(priority); 75 | } 76 | return self; 77 | }; 78 | } 79 | 80 | #pragma mark - NSLayoutRelation proxy 81 | 82 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { 83 | return ^id(id attr, NSLayoutRelation relation) { 84 | for (MASConstraint *constraint in self.childConstraints.copy) { 85 | constraint.equalToWithRelation(attr, relation); 86 | } 87 | return self; 88 | }; 89 | } 90 | 91 | #pragma mark - attribute chaining 92 | 93 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute { 94 | [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute]; 95 | return self; 96 | } 97 | 98 | #pragma mark - Animator proxy 99 | 100 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 101 | 102 | - (MASConstraint *)animator { 103 | for (MASConstraint *constraint in self.childConstraints) { 104 | [constraint animator]; 105 | } 106 | return self; 107 | } 108 | 109 | #endif 110 | 111 | #pragma mark - debug helpers 112 | 113 | - (MASConstraint * (^)(id))key { 114 | return ^id(id key) { 115 | self.mas_key = key; 116 | int i = 0; 117 | for (MASConstraint *constraint in self.childConstraints) { 118 | constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]); 119 | } 120 | return self; 121 | }; 122 | } 123 | 124 | #pragma mark - NSLayoutConstraint constant setters 125 | 126 | - (void)setInsets:(MASEdgeInsets)insets { 127 | for (MASConstraint *constraint in self.childConstraints) { 128 | constraint.insets = insets; 129 | } 130 | } 131 | 132 | - (void)setOffset:(CGFloat)offset { 133 | for (MASConstraint *constraint in self.childConstraints) { 134 | constraint.offset = offset; 135 | } 136 | } 137 | 138 | - (void)setSizeOffset:(CGSize)sizeOffset { 139 | for (MASConstraint *constraint in self.childConstraints) { 140 | constraint.sizeOffset = sizeOffset; 141 | } 142 | } 143 | 144 | - (void)setCenterOffset:(CGPoint)centerOffset { 145 | for (MASConstraint *constraint in self.childConstraints) { 146 | constraint.centerOffset = centerOffset; 147 | } 148 | } 149 | 150 | #pragma mark - MASConstraint 151 | 152 | - (void)activate { 153 | for (MASConstraint *constraint in self.childConstraints) { 154 | [constraint activate]; 155 | } 156 | } 157 | 158 | - (void)deactivate { 159 | for (MASConstraint *constraint in self.childConstraints) { 160 | [constraint deactivate]; 161 | } 162 | } 163 | 164 | - (void)install { 165 | for (MASConstraint *constraint in self.childConstraints) { 166 | constraint.updateExisting = self.updateExisting; 167 | [constraint install]; 168 | } 169 | } 170 | 171 | - (void)uninstall { 172 | for (MASConstraint *constraint in self.childConstraints) { 173 | [constraint uninstall]; 174 | } 175 | } 176 | 177 | @end 178 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASConstraint+Private.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint+Private.h 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 29/04/14. 6 | // Copyright (c) 2014 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | 11 | @protocol MASConstraintDelegate; 12 | 13 | 14 | @interface MASConstraint () 15 | 16 | /** 17 | * Whether or not to check for an existing constraint instead of adding constraint 18 | */ 19 | @property (nonatomic, assign) BOOL updateExisting; 20 | 21 | /** 22 | * Usually MASConstraintMaker but could be a parent MASConstraint 23 | */ 24 | @property (nonatomic, weak) id delegate; 25 | 26 | /** 27 | * Based on a provided value type, is equal to calling: 28 | * NSNumber - setOffset: 29 | * NSValue with CGPoint - setPointOffset: 30 | * NSValue with CGSize - setSizeOffset: 31 | * NSValue with MASEdgeInsets - setInsets: 32 | */ 33 | - (void)setLayoutConstantWithValue:(NSValue *)value; 34 | 35 | @end 36 | 37 | 38 | @interface MASConstraint (Abstract) 39 | 40 | /** 41 | * Sets the constraint relation to given NSLayoutRelation 42 | * returns a block which accepts one of the following: 43 | * MASViewAttribute, UIView, NSValue, NSArray 44 | * see readme for more details. 45 | */ 46 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation; 47 | 48 | /** 49 | * Override to set a custom chaining behaviour 50 | */ 51 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 52 | 53 | @end 54 | 55 | 56 | @protocol MASConstraintDelegate 57 | 58 | /** 59 | * Notifies the delegate when the constraint needs to be replaced with another constraint. For example 60 | * A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks 61 | */ 62 | - (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint; 63 | 64 | - (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * Enables Constraints to be created with chainable syntax 13 | * Constraint can represent single NSLayoutConstraint (MASViewConstraint) 14 | * or a group of NSLayoutConstraints (MASComposisteConstraint) 15 | */ 16 | @interface MASConstraint : NSObject 17 | 18 | // Chaining Support 19 | 20 | /** 21 | * Modifies the NSLayoutConstraint constant, 22 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 23 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 24 | */ 25 | - (MASConstraint * (^)(MASEdgeInsets insets))insets; 26 | 27 | /** 28 | * Modifies the NSLayoutConstraint constant, 29 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 30 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 31 | */ 32 | - (MASConstraint * (^)(CGSize offset))sizeOffset; 33 | 34 | /** 35 | * Modifies the NSLayoutConstraint constant, 36 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 37 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 38 | */ 39 | - (MASConstraint * (^)(CGPoint offset))centerOffset; 40 | 41 | /** 42 | * Modifies the NSLayoutConstraint constant 43 | */ 44 | - (MASConstraint * (^)(CGFloat offset))offset; 45 | 46 | /** 47 | * Modifies the NSLayoutConstraint constant based on a value type 48 | */ 49 | - (MASConstraint * (^)(NSValue *value))valueOffset; 50 | 51 | /** 52 | * Sets the NSLayoutConstraint multiplier property 53 | */ 54 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy; 55 | 56 | /** 57 | * Sets the NSLayoutConstraint multiplier to 1.0/dividedBy 58 | */ 59 | - (MASConstraint * (^)(CGFloat divider))dividedBy; 60 | 61 | /** 62 | * Sets the NSLayoutConstraint priority to a float or MASLayoutPriority 63 | */ 64 | - (MASConstraint * (^)(MASLayoutPriority priority))priority; 65 | 66 | /** 67 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityLow 68 | */ 69 | - (MASConstraint * (^)())priorityLow; 70 | 71 | /** 72 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium 73 | */ 74 | - (MASConstraint * (^)())priorityMedium; 75 | 76 | /** 77 | * Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh 78 | */ 79 | - (MASConstraint * (^)())priorityHigh; 80 | 81 | /** 82 | * Sets the constraint relation to NSLayoutRelationEqual 83 | * returns a block which accepts one of the following: 84 | * MASViewAttribute, UIView, NSValue, NSArray 85 | * see readme for more details. 86 | */ 87 | - (MASConstraint * (^)(id attr))equalTo; 88 | 89 | /** 90 | * Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual 91 | * returns a block which accepts one of the following: 92 | * MASViewAttribute, UIView, NSValue, NSArray 93 | * see readme for more details. 94 | */ 95 | - (MASConstraint * (^)(id attr))greaterThanOrEqualTo; 96 | 97 | /** 98 | * Sets the constraint relation to NSLayoutRelationLessThanOrEqual 99 | * returns a block which accepts one of the following: 100 | * MASViewAttribute, UIView, NSValue, NSArray 101 | * see readme for more details. 102 | */ 103 | - (MASConstraint * (^)(id attr))lessThanOrEqualTo; 104 | 105 | /** 106 | * Optional semantic property which has no effect but improves the readability of constraint 107 | */ 108 | - (MASConstraint *)with; 109 | 110 | /** 111 | * Optional semantic property which has no effect but improves the readability of constraint 112 | */ 113 | - (MASConstraint *)and; 114 | 115 | /** 116 | * Creates a new MASCompositeConstraint with the called attribute and reciever 117 | */ 118 | - (MASConstraint *)left; 119 | - (MASConstraint *)top; 120 | - (MASConstraint *)right; 121 | - (MASConstraint *)bottom; 122 | - (MASConstraint *)leading; 123 | - (MASConstraint *)trailing; 124 | - (MASConstraint *)width; 125 | - (MASConstraint *)height; 126 | - (MASConstraint *)centerX; 127 | - (MASConstraint *)centerY; 128 | - (MASConstraint *)baseline; 129 | 130 | #if TARGET_OS_IPHONE 131 | 132 | - (MASConstraint *)leftMargin; 133 | - (MASConstraint *)rightMargin; 134 | - (MASConstraint *)topMargin; 135 | - (MASConstraint *)bottomMargin; 136 | - (MASConstraint *)leadingMargin; 137 | - (MASConstraint *)trailingMargin; 138 | - (MASConstraint *)centerXWithinMargins; 139 | - (MASConstraint *)centerYWithinMargins; 140 | 141 | #endif 142 | 143 | 144 | /** 145 | * Sets the constraint debug name 146 | */ 147 | - (MASConstraint * (^)(id key))key; 148 | 149 | // NSLayoutConstraint constant Setters 150 | // for use outside of mas_updateConstraints/mas_makeConstraints blocks 151 | 152 | /** 153 | * Modifies the NSLayoutConstraint constant, 154 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 155 | * NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight 156 | */ 157 | - (void)setInsets:(MASEdgeInsets)insets; 158 | 159 | /** 160 | * Modifies the NSLayoutConstraint constant, 161 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 162 | * NSLayoutAttributeWidth, NSLayoutAttributeHeight 163 | */ 164 | - (void)setSizeOffset:(CGSize)sizeOffset; 165 | 166 | /** 167 | * Modifies the NSLayoutConstraint constant, 168 | * only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following 169 | * NSLayoutAttributeCenterX, NSLayoutAttributeCenterY 170 | */ 171 | - (void)setCenterOffset:(CGPoint)centerOffset; 172 | 173 | /** 174 | * Modifies the NSLayoutConstraint constant 175 | */ 176 | - (void)setOffset:(CGFloat)offset; 177 | 178 | 179 | // NSLayoutConstraint Installation support 180 | 181 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 182 | /** 183 | * Whether or not to go through the animator proxy when modifying the constraint 184 | */ 185 | @property (nonatomic, copy, readonly) MASConstraint *animator; 186 | #endif 187 | 188 | /** 189 | * Activates an NSLayoutConstraint if it's supported by an OS. 190 | * Invokes install otherwise. 191 | */ 192 | - (void)activate; 193 | 194 | /** 195 | * Deactivates previously installed/activated NSLayoutConstraint. 196 | */ 197 | - (void)deactivate; 198 | 199 | /** 200 | * Creates a NSLayoutConstraint and adds it to the appropriate view. 201 | */ 202 | - (void)install; 203 | 204 | /** 205 | * Removes previously installed NSLayoutConstraint 206 | */ 207 | - (void)uninstall; 208 | 209 | @end 210 | 211 | 212 | /** 213 | * Convenience auto-boxing macros for MASConstraint methods. 214 | * 215 | * Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax. 216 | * A potential drawback of this is that the unprefixed macros will appear in global scope. 217 | */ 218 | #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 219 | #define mas_greaterThanOrEqualTo(...) greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 220 | #define mas_lessThanOrEqualTo(...) lessThanOrEqualTo(MASBoxValue((__VA_ARGS__))) 221 | 222 | #define mas_offset(...) valueOffset(MASBoxValue((__VA_ARGS__))) 223 | 224 | 225 | #ifdef MAS_SHORTHAND_GLOBALS 226 | 227 | #define equalTo(...) mas_equalTo(__VA_ARGS__) 228 | #define greaterThanOrEqualTo(...) mas_greaterThanOrEqualTo(__VA_ARGS__) 229 | #define lessThanOrEqualTo(...) mas_lessThanOrEqualTo(__VA_ARGS__) 230 | 231 | #define offset(...) mas_offset(__VA_ARGS__) 232 | 233 | #endif 234 | 235 | 236 | @interface MASConstraint (AutoboxingSupport) 237 | 238 | /** 239 | * Aliases to corresponding relation methods (for shorthand macros) 240 | * Also needed to aid autocompletion 241 | */ 242 | - (MASConstraint * (^)(id attr))mas_equalTo; 243 | - (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo; 244 | - (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo; 245 | 246 | /** 247 | * A dummy method to aid autocompletion 248 | */ 249 | - (MASConstraint * (^)(id offset))mas_offset; 250 | 251 | @end 252 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.m 3 | // Masonry 4 | // 5 | // Created by Nick Tymchenko on 1/20/14. 6 | // 7 | 8 | #import "MASConstraint.h" 9 | #import "MASConstraint+Private.h" 10 | 11 | #define MASMethodNotImplemented() \ 12 | @throw [NSException exceptionWithName:NSInternalInconsistencyException \ 13 | reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \ 14 | userInfo:nil] 15 | 16 | @implementation MASConstraint 17 | 18 | #pragma mark - Init 19 | 20 | - (id)init { 21 | NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly."); 22 | return [super init]; 23 | } 24 | 25 | #pragma mark - NSLayoutRelation proxies 26 | 27 | - (MASConstraint * (^)(id))equalTo { 28 | return ^id(id attribute) { 29 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 30 | }; 31 | } 32 | 33 | - (MASConstraint * (^)(id))mas_equalTo { 34 | return ^id(id attribute) { 35 | return self.equalToWithRelation(attribute, NSLayoutRelationEqual); 36 | }; 37 | } 38 | 39 | - (MASConstraint * (^)(id))greaterThanOrEqualTo { 40 | return ^id(id attribute) { 41 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 42 | }; 43 | } 44 | 45 | - (MASConstraint * (^)(id))mas_greaterThanOrEqualTo { 46 | return ^id(id attribute) { 47 | return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual); 48 | }; 49 | } 50 | 51 | - (MASConstraint * (^)(id))lessThanOrEqualTo { 52 | return ^id(id attribute) { 53 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 54 | }; 55 | } 56 | 57 | - (MASConstraint * (^)(id))mas_lessThanOrEqualTo { 58 | return ^id(id attribute) { 59 | return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual); 60 | }; 61 | } 62 | 63 | #pragma mark - MASLayoutPriority proxies 64 | 65 | - (MASConstraint * (^)())priorityLow { 66 | return ^id{ 67 | self.priority(MASLayoutPriorityDefaultLow); 68 | return self; 69 | }; 70 | } 71 | 72 | - (MASConstraint * (^)())priorityMedium { 73 | return ^id{ 74 | self.priority(MASLayoutPriorityDefaultMedium); 75 | return self; 76 | }; 77 | } 78 | 79 | - (MASConstraint * (^)())priorityHigh { 80 | return ^id{ 81 | self.priority(MASLayoutPriorityDefaultHigh); 82 | return self; 83 | }; 84 | } 85 | 86 | #pragma mark - NSLayoutConstraint constant proxies 87 | 88 | - (MASConstraint * (^)(MASEdgeInsets))insets { 89 | return ^id(MASEdgeInsets insets){ 90 | self.insets = insets; 91 | return self; 92 | }; 93 | } 94 | 95 | - (MASConstraint * (^)(CGSize))sizeOffset { 96 | return ^id(CGSize offset) { 97 | self.sizeOffset = offset; 98 | return self; 99 | }; 100 | } 101 | 102 | - (MASConstraint * (^)(CGPoint))centerOffset { 103 | return ^id(CGPoint offset) { 104 | self.centerOffset = offset; 105 | return self; 106 | }; 107 | } 108 | 109 | - (MASConstraint * (^)(CGFloat))offset { 110 | return ^id(CGFloat offset){ 111 | self.offset = offset; 112 | return self; 113 | }; 114 | } 115 | 116 | - (MASConstraint * (^)(NSValue *value))valueOffset { 117 | return ^id(NSValue *offset) { 118 | NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset); 119 | [self setLayoutConstantWithValue:offset]; 120 | return self; 121 | }; 122 | } 123 | 124 | - (MASConstraint * (^)(id offset))mas_offset { 125 | // Will never be called due to macro 126 | return nil; 127 | } 128 | 129 | #pragma mark - NSLayoutConstraint constant setter 130 | 131 | - (void)setLayoutConstantWithValue:(NSValue *)value { 132 | if ([value isKindOfClass:NSNumber.class]) { 133 | self.offset = [(NSNumber *)value doubleValue]; 134 | } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) { 135 | CGPoint point; 136 | [value getValue:&point]; 137 | self.centerOffset = point; 138 | } else if (strcmp(value.objCType, @encode(CGSize)) == 0) { 139 | CGSize size; 140 | [value getValue:&size]; 141 | self.sizeOffset = size; 142 | } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) { 143 | MASEdgeInsets insets; 144 | [value getValue:&insets]; 145 | self.insets = insets; 146 | } else { 147 | NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value); 148 | } 149 | } 150 | 151 | #pragma mark - Semantic properties 152 | 153 | - (MASConstraint *)with { 154 | return self; 155 | } 156 | 157 | - (MASConstraint *)and { 158 | return self; 159 | } 160 | 161 | #pragma mark - Chaining 162 | 163 | - (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute { 164 | MASMethodNotImplemented(); 165 | } 166 | 167 | - (MASConstraint *)left { 168 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft]; 169 | } 170 | 171 | - (MASConstraint *)top { 172 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop]; 173 | } 174 | 175 | - (MASConstraint *)right { 176 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight]; 177 | } 178 | 179 | - (MASConstraint *)bottom { 180 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom]; 181 | } 182 | 183 | - (MASConstraint *)leading { 184 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading]; 185 | } 186 | 187 | - (MASConstraint *)trailing { 188 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing]; 189 | } 190 | 191 | - (MASConstraint *)width { 192 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth]; 193 | } 194 | 195 | - (MASConstraint *)height { 196 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight]; 197 | } 198 | 199 | - (MASConstraint *)centerX { 200 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX]; 201 | } 202 | 203 | - (MASConstraint *)centerY { 204 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY]; 205 | } 206 | 207 | - (MASConstraint *)baseline { 208 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline]; 209 | } 210 | 211 | #if TARGET_OS_IPHONE 212 | 213 | - (MASConstraint *)leftMargin { 214 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin]; 215 | } 216 | 217 | - (MASConstraint *)rightMargin { 218 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin]; 219 | } 220 | 221 | - (MASConstraint *)topMargin { 222 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin]; 223 | } 224 | 225 | - (MASConstraint *)bottomMargin { 226 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin]; 227 | } 228 | 229 | - (MASConstraint *)leadingMargin { 230 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin]; 231 | } 232 | 233 | - (MASConstraint *)trailingMargin { 234 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin]; 235 | } 236 | 237 | - (MASConstraint *)centerXWithinMargins { 238 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 239 | } 240 | 241 | - (MASConstraint *)centerYWithinMargins { 242 | return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 243 | } 244 | 245 | #endif 246 | 247 | #pragma mark - Abstract 248 | 249 | - (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); } 250 | 251 | - (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); } 252 | 253 | - (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); } 254 | 255 | - (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); } 256 | 257 | - (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); } 258 | 259 | - (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); } 260 | 261 | - (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); } 262 | 263 | - (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); } 264 | 265 | - (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); } 266 | 267 | #if TARGET_OS_MAC && !TARGET_OS_IPHONE 268 | 269 | - (MASConstraint *)animator { MASMethodNotImplemented(); } 270 | 271 | #endif 272 | 273 | - (void)activate { MASMethodNotImplemented(); } 274 | 275 | - (void)deactivate { MASMethodNotImplemented(); } 276 | 277 | - (void)install { MASMethodNotImplemented(); } 278 | 279 | - (void)uninstall { MASMethodNotImplemented(); } 280 | 281 | @end 282 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASConstraintMaker.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraintBuilder.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASConstraint.h" 10 | #import "MASUtilities.h" 11 | 12 | typedef NS_OPTIONS(NSInteger, MASAttribute) { 13 | MASAttributeLeft = 1 << NSLayoutAttributeLeft, 14 | MASAttributeRight = 1 << NSLayoutAttributeRight, 15 | MASAttributeTop = 1 << NSLayoutAttributeTop, 16 | MASAttributeBottom = 1 << NSLayoutAttributeBottom, 17 | MASAttributeLeading = 1 << NSLayoutAttributeLeading, 18 | MASAttributeTrailing = 1 << NSLayoutAttributeTrailing, 19 | MASAttributeWidth = 1 << NSLayoutAttributeWidth, 20 | MASAttributeHeight = 1 << NSLayoutAttributeHeight, 21 | MASAttributeCenterX = 1 << NSLayoutAttributeCenterX, 22 | MASAttributeCenterY = 1 << NSLayoutAttributeCenterY, 23 | MASAttributeBaseline = 1 << NSLayoutAttributeBaseline, 24 | 25 | #if TARGET_OS_IPHONE 26 | 27 | MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin, 28 | MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin, 29 | MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin, 30 | MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin, 31 | MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin, 32 | MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin, 33 | MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins, 34 | MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins, 35 | 36 | #endif 37 | 38 | }; 39 | 40 | /** 41 | * Provides factory methods for creating MASConstraints. 42 | * Constraints are collected until they are ready to be installed 43 | * 44 | */ 45 | @interface MASConstraintMaker : NSObject 46 | 47 | /** 48 | * The following properties return a new MASViewConstraint 49 | * with the first item set to the makers associated view and the appropriate MASViewAttribute 50 | */ 51 | @property (nonatomic, strong, readonly) MASConstraint *left; 52 | @property (nonatomic, strong, readonly) MASConstraint *top; 53 | @property (nonatomic, strong, readonly) MASConstraint *right; 54 | @property (nonatomic, strong, readonly) MASConstraint *bottom; 55 | @property (nonatomic, strong, readonly) MASConstraint *leading; 56 | @property (nonatomic, strong, readonly) MASConstraint *trailing; 57 | @property (nonatomic, strong, readonly) MASConstraint *width; 58 | @property (nonatomic, strong, readonly) MASConstraint *height; 59 | @property (nonatomic, strong, readonly) MASConstraint *centerX; 60 | @property (nonatomic, strong, readonly) MASConstraint *centerY; 61 | @property (nonatomic, strong, readonly) MASConstraint *baseline; 62 | 63 | #if TARGET_OS_IPHONE 64 | 65 | @property (nonatomic, strong, readonly) MASConstraint *leftMargin; 66 | @property (nonatomic, strong, readonly) MASConstraint *rightMargin; 67 | @property (nonatomic, strong, readonly) MASConstraint *topMargin; 68 | @property (nonatomic, strong, readonly) MASConstraint *bottomMargin; 69 | @property (nonatomic, strong, readonly) MASConstraint *leadingMargin; 70 | @property (nonatomic, strong, readonly) MASConstraint *trailingMargin; 71 | @property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins; 72 | @property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins; 73 | 74 | #endif 75 | 76 | /** 77 | * Returns a block which creates a new MASCompositeConstraint with the first item set 78 | * to the makers associated view and children corresponding to the set bits in the 79 | * MASAttribute parameter. Combine multiple attributes via binary-or. 80 | */ 81 | @property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs); 82 | 83 | /** 84 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges 85 | * which generates the appropriate MASViewConstraint children (top, left, bottom, right) 86 | * with the first item set to the makers associated view 87 | */ 88 | @property (nonatomic, strong, readonly) MASConstraint *edges; 89 | 90 | /** 91 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize 92 | * which generates the appropriate MASViewConstraint children (width, height) 93 | * with the first item set to the makers associated view 94 | */ 95 | @property (nonatomic, strong, readonly) MASConstraint *size; 96 | 97 | /** 98 | * Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter 99 | * which generates the appropriate MASViewConstraint children (centerX, centerY) 100 | * with the first item set to the makers associated view 101 | */ 102 | @property (nonatomic, strong, readonly) MASConstraint *center; 103 | 104 | /** 105 | * Whether or not to check for an existing constraint instead of adding constraint 106 | */ 107 | @property (nonatomic, assign) BOOL updateExisting; 108 | 109 | /** 110 | * Whether or not to remove existing constraints prior to installing 111 | */ 112 | @property (nonatomic, assign) BOOL removeExisting; 113 | 114 | /** 115 | * initialises the maker with a default view 116 | * 117 | * @param view any MASConstrait are created with this view as the first item 118 | * 119 | * @return a new MASConstraintMaker 120 | */ 121 | - (id)initWithView:(MAS_VIEW *)view; 122 | 123 | /** 124 | * Calls install method on any MASConstraints which have been created by this maker 125 | * 126 | * @return an array of all the installed MASConstraints 127 | */ 128 | - (NSArray *)install; 129 | 130 | - (MASConstraint * (^)(dispatch_block_t))group; 131 | 132 | @end 133 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASLayoutConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * When you are debugging or printing the constraints attached to a view this subclass 13 | * makes it easier to identify which constraints have been created via Masonry 14 | */ 15 | @interface MASLayoutConstraint : NSLayoutConstraint 16 | 17 | /** 18 | * a key to associate with this constraint 19 | */ 20 | @property (nonatomic, strong) id mas_key; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASLayoutConstraint.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASLayoutConstraint.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASLayoutConstraint.h" 10 | 11 | @implementation MASLayoutConstraint 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASUtilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASUtilities.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 19/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #if TARGET_OS_IPHONE 12 | 13 | #import 14 | #define MAS_VIEW UIView 15 | #define MAS_VIEW_CONTROLLER UIViewController 16 | #define MASEdgeInsets UIEdgeInsets 17 | 18 | typedef UILayoutPriority MASLayoutPriority; 19 | static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired; 20 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh; 21 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500; 22 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow; 23 | static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel; 24 | 25 | #elif TARGET_OS_MAC 26 | 27 | #import 28 | #define MAS_VIEW NSView 29 | #define MASEdgeInsets NSEdgeInsets 30 | 31 | typedef NSLayoutPriority MASLayoutPriority; 32 | static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired; 33 | static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh; 34 | static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow; 35 | static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501; 36 | static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut; 37 | static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow; 38 | static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow; 39 | static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression; 40 | 41 | #endif 42 | 43 | /** 44 | * Allows you to attach keys to objects matching the variable names passed. 45 | * 46 | * view1.mas_key = @"view1", view2.mas_key = @"view2"; 47 | * 48 | * is equivalent to: 49 | * 50 | * MASAttachKeys(view1, view2); 51 | */ 52 | #define MASAttachKeys(...) \ 53 | NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__); \ 54 | for (id key in keyPairs.allKeys) { \ 55 | id obj = keyPairs[key]; \ 56 | NSAssert([obj respondsToSelector:@selector(setMas_key:)], \ 57 | @"Cannot attach mas_key to %@", obj); \ 58 | [obj setMas_key:key]; \ 59 | } 60 | 61 | /** 62 | * Used to create object hashes 63 | * Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html 64 | */ 65 | #define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger)) 66 | #define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch))) 67 | 68 | /** 69 | * Given a scalar or struct value, wraps it in NSValue 70 | * Based on EXPObjectify: https://github.com/specta/expecta 71 | */ 72 | static inline id _MASBoxValue(const char *type, ...) { 73 | va_list v; 74 | va_start(v, type); 75 | id obj = nil; 76 | if (strcmp(type, @encode(id)) == 0) { 77 | id actual = va_arg(v, id); 78 | obj = actual; 79 | } else if (strcmp(type, @encode(CGPoint)) == 0) { 80 | CGPoint actual = (CGPoint)va_arg(v, CGPoint); 81 | obj = [NSValue value:&actual withObjCType:type]; 82 | } else if (strcmp(type, @encode(CGSize)) == 0) { 83 | CGSize actual = (CGSize)va_arg(v, CGSize); 84 | obj = [NSValue value:&actual withObjCType:type]; 85 | } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) { 86 | MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets); 87 | obj = [NSValue value:&actual withObjCType:type]; 88 | } else if (strcmp(type, @encode(double)) == 0) { 89 | double actual = (double)va_arg(v, double); 90 | obj = [NSNumber numberWithDouble:actual]; 91 | } else if (strcmp(type, @encode(float)) == 0) { 92 | float actual = (float)va_arg(v, double); 93 | obj = [NSNumber numberWithFloat:actual]; 94 | } else if (strcmp(type, @encode(int)) == 0) { 95 | int actual = (int)va_arg(v, int); 96 | obj = [NSNumber numberWithInt:actual]; 97 | } else if (strcmp(type, @encode(long)) == 0) { 98 | long actual = (long)va_arg(v, long); 99 | obj = [NSNumber numberWithLong:actual]; 100 | } else if (strcmp(type, @encode(long long)) == 0) { 101 | long long actual = (long long)va_arg(v, long long); 102 | obj = [NSNumber numberWithLongLong:actual]; 103 | } else if (strcmp(type, @encode(short)) == 0) { 104 | short actual = (short)va_arg(v, int); 105 | obj = [NSNumber numberWithShort:actual]; 106 | } else if (strcmp(type, @encode(char)) == 0) { 107 | char actual = (char)va_arg(v, int); 108 | obj = [NSNumber numberWithChar:actual]; 109 | } else if (strcmp(type, @encode(bool)) == 0) { 110 | bool actual = (bool)va_arg(v, int); 111 | obj = [NSNumber numberWithBool:actual]; 112 | } else if (strcmp(type, @encode(unsigned char)) == 0) { 113 | unsigned char actual = (unsigned char)va_arg(v, unsigned int); 114 | obj = [NSNumber numberWithUnsignedChar:actual]; 115 | } else if (strcmp(type, @encode(unsigned int)) == 0) { 116 | unsigned int actual = (unsigned int)va_arg(v, unsigned int); 117 | obj = [NSNumber numberWithUnsignedInt:actual]; 118 | } else if (strcmp(type, @encode(unsigned long)) == 0) { 119 | unsigned long actual = (unsigned long)va_arg(v, unsigned long); 120 | obj = [NSNumber numberWithUnsignedLong:actual]; 121 | } else if (strcmp(type, @encode(unsigned long long)) == 0) { 122 | unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long); 123 | obj = [NSNumber numberWithUnsignedLongLong:actual]; 124 | } else if (strcmp(type, @encode(unsigned short)) == 0) { 125 | unsigned short actual = (unsigned short)va_arg(v, unsigned int); 126 | obj = [NSNumber numberWithUnsignedShort:actual]; 127 | } 128 | va_end(v); 129 | return obj; 130 | } 131 | 132 | #define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value)) 133 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASViewAttribute.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * An immutable tuple which stores the view and the related NSLayoutAttribute. 13 | * Describes part of either the left or right hand side of a constraint equation 14 | */ 15 | @interface MASViewAttribute : NSObject 16 | 17 | /** 18 | * The view which the reciever relates to. Can be nil if item is not a view. 19 | */ 20 | @property (nonatomic, weak, readonly) MAS_VIEW *view; 21 | 22 | /** 23 | * The item which the reciever relates to. 24 | */ 25 | @property (nonatomic, weak, readonly) id item; 26 | 27 | /** 28 | * The attribute which the reciever relates to 29 | */ 30 | @property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute; 31 | 32 | /** 33 | * Convenience initializer. 34 | */ 35 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute; 36 | 37 | /** 38 | * The designated initializer. 39 | */ 40 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute; 41 | 42 | /** 43 | * Determine whether the layoutAttribute is a size attribute 44 | * 45 | * @return YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight 46 | */ 47 | - (BOOL)isSizeAttribute; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASViewAttribute.m: -------------------------------------------------------------------------------- 1 | // 2 | // MASAttribute.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 21/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | 11 | @implementation MASViewAttribute 12 | 13 | - (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute { 14 | self = [self initWithView:view item:view layoutAttribute:layoutAttribute]; 15 | return self; 16 | } 17 | 18 | - (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute { 19 | self = [super init]; 20 | if (!self) return nil; 21 | 22 | _view = view; 23 | _item = item; 24 | _layoutAttribute = layoutAttribute; 25 | 26 | return self; 27 | } 28 | 29 | - (BOOL)isSizeAttribute { 30 | return self.layoutAttribute == NSLayoutAttributeWidth 31 | || self.layoutAttribute == NSLayoutAttributeHeight; 32 | } 33 | 34 | - (BOOL)isEqual:(MASViewAttribute *)viewAttribute { 35 | if ([viewAttribute isKindOfClass:self.class]) { 36 | return self.view == viewAttribute.view 37 | && self.layoutAttribute == viewAttribute.layoutAttribute; 38 | } 39 | return [super isEqual:viewAttribute]; 40 | } 41 | 42 | - (NSUInteger)hash { 43 | return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/MASViewConstraint.h: -------------------------------------------------------------------------------- 1 | // 2 | // MASConstraint.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASViewAttribute.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | #import "MASUtilities.h" 13 | 14 | /** 15 | * A single constraint. 16 | * Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view 17 | */ 18 | @interface MASViewConstraint : MASConstraint 19 | 20 | /** 21 | * First item/view and first attribute of the NSLayoutConstraint 22 | */ 23 | @property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute; 24 | 25 | /** 26 | * Second item/view and second attribute of the NSLayoutConstraint 27 | */ 28 | @property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute; 29 | 30 | /** 31 | * initialises the MASViewConstraint with the first part of the equation 32 | * 33 | * @param firstViewAttribute view.mas_left, view.mas_width etc. 34 | * 35 | * @return a new view constraint 36 | */ 37 | - (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute; 38 | 39 | /** 40 | * Returns all MASViewConstraints installed with this view as a first item. 41 | * 42 | * @param view A view to retrieve constraints for. 43 | * 44 | * @return An array of MASViewConstraints. 45 | */ 46 | + (NSArray *)installedConstraintsForView:(MAS_VIEW *)view; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/Masonry.h: -------------------------------------------------------------------------------- 1 | // 2 | // Masonry.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Masonry. 12 | FOUNDATION_EXPORT double MasonryVersionNumber; 13 | 14 | //! Project version string for Masonry. 15 | FOUNDATION_EXPORT const unsigned char MasonryVersionString[]; 16 | 17 | #import "MASUtilities.h" 18 | #import "View+MASAdditions.h" 19 | #import "View+MASShorthandAdditions.h" 20 | #import "ViewController+MASAdditions.h" 21 | #import "NSArray+MASAdditions.h" 22 | #import "NSArray+MASShorthandAdditions.h" 23 | #import "MASConstraint.h" 24 | #import "MASCompositeConstraint.h" 25 | #import "MASViewAttribute.h" 26 | #import "MASViewConstraint.h" 27 | #import "MASConstraintMaker.h" 28 | #import "MASLayoutConstraint.h" 29 | #import "NSLayoutConstraint+MASDebugAdditions.h" 30 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/NSArray+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.h 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | @interface NSArray (MASAdditions) 14 | 15 | /** 16 | * Creates a MASConstraintMaker with each view in the callee. 17 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view 18 | * 19 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 20 | * 21 | * @return Array of created MASConstraints 22 | */ 23 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 24 | 25 | /** 26 | * Creates a MASConstraintMaker with each view in the callee. 27 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 28 | * If an existing constraint exists then it will be updated instead. 29 | * 30 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 31 | * 32 | * @return Array of created/updated MASConstraints 33 | */ 34 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 35 | 36 | /** 37 | * Creates a MASConstraintMaker with each view in the callee. 38 | * Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view. 39 | * All constraints previously installed for the views will be removed. 40 | * 41 | * @param block scope within which you can build up the constraints which you wish to apply to each view. 42 | * 43 | * @return Array of created/updated MASConstraints 44 | */ 45 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/NSArray+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASAdditions.m 3 | // 4 | // 5 | // Created by Daniel Hammond on 11/26/13. 6 | // 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | #import "View+MASAdditions.h" 11 | 12 | @implementation NSArray (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { 15 | NSMutableArray *constraints = [NSMutableArray array]; 16 | for (MAS_VIEW *view in self) { 17 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 18 | [constraints addObjectsFromArray:[view mas_makeConstraints:block]]; 19 | } 20 | return constraints; 21 | } 22 | 23 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block { 24 | NSMutableArray *constraints = [NSMutableArray array]; 25 | for (MAS_VIEW *view in self) { 26 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 27 | [constraints addObjectsFromArray:[view mas_updateConstraints:block]]; 28 | } 29 | return constraints; 30 | } 31 | 32 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 33 | NSMutableArray *constraints = [NSMutableArray array]; 34 | for (MAS_VIEW *view in self) { 35 | NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views"); 36 | [constraints addObjectsFromArray:[view mas_remakeConstraints:block]]; 37 | } 38 | return constraints; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/NSArray+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSArray+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSArray+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand array additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface NSArray (MASShorthandAdditions) 18 | 19 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 20 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 21 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 22 | 23 | @end 24 | 25 | @implementation NSArray (MASShorthandAdditions) 26 | 27 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 28 | return [self mas_makeConstraints:block]; 29 | } 30 | 31 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 32 | return [self mas_updateConstraints:block]; 33 | } 34 | 35 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 36 | return [self mas_remakeConstraints:block]; 37 | } 38 | 39 | @end 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/NSLayoutConstraint+MASDebugAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | 11 | /** 12 | * makes debug and log output of NSLayoutConstraints more readable 13 | */ 14 | @interface NSLayoutConstraint (MASDebugAdditions) 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/NSLayoutConstraint+MASDebugAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+MASDebugAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 3/08/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "NSLayoutConstraint+MASDebugAdditions.h" 10 | #import "MASConstraint.h" 11 | #import "MASLayoutConstraint.h" 12 | 13 | @implementation NSLayoutConstraint (MASDebugAdditions) 14 | 15 | #pragma mark - description maps 16 | 17 | + (NSDictionary *)layoutRelationDescriptionsByValue { 18 | static dispatch_once_t once; 19 | static NSDictionary *descriptionMap; 20 | dispatch_once(&once, ^{ 21 | descriptionMap = @{ 22 | @(NSLayoutRelationEqual) : @"==", 23 | @(NSLayoutRelationGreaterThanOrEqual) : @">=", 24 | @(NSLayoutRelationLessThanOrEqual) : @"<=", 25 | }; 26 | }); 27 | return descriptionMap; 28 | } 29 | 30 | + (NSDictionary *)layoutAttributeDescriptionsByValue { 31 | static dispatch_once_t once; 32 | static NSDictionary *descriptionMap; 33 | dispatch_once(&once, ^{ 34 | descriptionMap = @{ 35 | @(NSLayoutAttributeTop) : @"top", 36 | @(NSLayoutAttributeLeft) : @"left", 37 | @(NSLayoutAttributeBottom) : @"bottom", 38 | @(NSLayoutAttributeRight) : @"right", 39 | @(NSLayoutAttributeLeading) : @"leading", 40 | @(NSLayoutAttributeTrailing) : @"trailing", 41 | @(NSLayoutAttributeWidth) : @"width", 42 | @(NSLayoutAttributeHeight) : @"height", 43 | @(NSLayoutAttributeCenterX) : @"centerX", 44 | @(NSLayoutAttributeCenterY) : @"centerY", 45 | @(NSLayoutAttributeBaseline) : @"baseline", 46 | 47 | #if TARGET_OS_IPHONE 48 | @(NSLayoutAttributeLeftMargin) : @"leftMargin", 49 | @(NSLayoutAttributeRightMargin) : @"rightMargin", 50 | @(NSLayoutAttributeTopMargin) : @"topMargin", 51 | @(NSLayoutAttributeBottomMargin) : @"bottomMargin", 52 | @(NSLayoutAttributeLeadingMargin) : @"leadingMargin", 53 | @(NSLayoutAttributeTrailingMargin) : @"trailingMargin", 54 | @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins", 55 | @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins", 56 | #endif 57 | 58 | }; 59 | 60 | }); 61 | return descriptionMap; 62 | } 63 | 64 | 65 | + (NSDictionary *)layoutPriorityDescriptionsByValue { 66 | static dispatch_once_t once; 67 | static NSDictionary *descriptionMap; 68 | dispatch_once(&once, ^{ 69 | #if TARGET_OS_IPHONE 70 | descriptionMap = @{ 71 | @(MASLayoutPriorityDefaultHigh) : @"high", 72 | @(MASLayoutPriorityDefaultLow) : @"low", 73 | @(MASLayoutPriorityDefaultMedium) : @"medium", 74 | @(MASLayoutPriorityRequired) : @"required", 75 | @(MASLayoutPriorityFittingSizeLevel) : @"fitting size", 76 | }; 77 | #elif TARGET_OS_MAC 78 | descriptionMap = @{ 79 | @(MASLayoutPriorityDefaultHigh) : @"high", 80 | @(MASLayoutPriorityDragThatCanResizeWindow) : @"drag can resize window", 81 | @(MASLayoutPriorityDefaultMedium) : @"medium", 82 | @(MASLayoutPriorityWindowSizeStayPut) : @"window size stay put", 83 | @(MASLayoutPriorityDragThatCannotResizeWindow) : @"drag cannot resize window", 84 | @(MASLayoutPriorityDefaultLow) : @"low", 85 | @(MASLayoutPriorityFittingSizeCompression) : @"fitting size", 86 | @(MASLayoutPriorityRequired) : @"required", 87 | }; 88 | #endif 89 | }); 90 | return descriptionMap; 91 | } 92 | 93 | #pragma mark - description override 94 | 95 | + (NSString *)descriptionForObject:(id)obj { 96 | if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) { 97 | return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]]; 98 | } 99 | return [NSString stringWithFormat:@"%@:%p", [obj class], obj]; 100 | } 101 | 102 | - (NSString *)description { 103 | NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"]; 104 | 105 | [description appendString:[self.class descriptionForObject:self]]; 106 | 107 | [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]]; 108 | if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) { 109 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.firstAttribute)]]; 110 | } 111 | 112 | [description appendFormat:@" %@", [self.class.layoutRelationDescriptionsByValue objectForKey:@(self.relation)]]; 113 | 114 | if (self.secondItem) { 115 | [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]]; 116 | } 117 | if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) { 118 | [description appendFormat:@".%@", [self.class.layoutAttributeDescriptionsByValue objectForKey:@(self.secondAttribute)]]; 119 | } 120 | 121 | if (self.multiplier != 1) { 122 | [description appendFormat:@" * %g", self.multiplier]; 123 | } 124 | 125 | if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) { 126 | [description appendFormat:@" %g", self.constant]; 127 | } else { 128 | if (self.constant) { 129 | [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)]; 130 | } 131 | } 132 | 133 | if (self.priority != MASLayoutPriorityRequired) { 134 | [description appendFormat:@" ^%@", [self.class.layoutPriorityDescriptionsByValue objectForKey:@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]]; 135 | } 136 | 137 | [description appendString:@">"]; 138 | return description; 139 | } 140 | 141 | @end 142 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/View+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | /** 14 | * Provides constraint maker block 15 | * and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs 16 | */ 17 | @interface MAS_VIEW (MASAdditions) 18 | 19 | /** 20 | * following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute 21 | */ 22 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_left; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_top; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_right; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leading; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_width; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_height; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX; 31 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY; 32 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline; 33 | @property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr); 34 | 35 | #if TARGET_OS_IPHONE 36 | 37 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin; 42 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin; 43 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins; 44 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins; 45 | 46 | #endif 47 | 48 | /** 49 | * a key to associate with this view 50 | */ 51 | @property (nonatomic, strong) id mas_key; 52 | 53 | /** 54 | * Finds the closest common superview between this view and another view 55 | * 56 | * @param view other view 57 | * 58 | * @return returns nil if common superview could not be found 59 | */ 60 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view; 61 | 62 | /** 63 | * Creates a MASConstraintMaker with the callee view. 64 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing 65 | * 66 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 67 | * 68 | * @return Array of created MASConstraints 69 | */ 70 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block; 71 | 72 | /** 73 | * Creates a MASConstraintMaker with the callee view. 74 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 75 | * If an existing constraint exists then it will be updated instead. 76 | * 77 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 78 | * 79 | * @return Array of created/updated MASConstraints 80 | */ 81 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block; 82 | 83 | /** 84 | * Creates a MASConstraintMaker with the callee view. 85 | * Any constraints defined are added to the view or the appropriate superview once the block has finished executing. 86 | * All constraints previously installed for the view will be removed. 87 | * 88 | * @param block scope within which you can build up the constraints which you wish to apply to the view. 89 | * 90 | * @return Array of created/updated MASConstraints 91 | */ 92 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block; 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/View+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 20/07/13. 6 | // Copyright (c) 2013 cloudling. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | #import 11 | 12 | @implementation MAS_VIEW (MASAdditions) 13 | 14 | - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block { 15 | self.translatesAutoresizingMaskIntoConstraints = NO; 16 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 17 | block(constraintMaker); 18 | return [constraintMaker install]; 19 | } 20 | 21 | - (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block { 22 | self.translatesAutoresizingMaskIntoConstraints = NO; 23 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 24 | constraintMaker.updateExisting = YES; 25 | block(constraintMaker); 26 | return [constraintMaker install]; 27 | } 28 | 29 | - (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block { 30 | self.translatesAutoresizingMaskIntoConstraints = NO; 31 | MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self]; 32 | constraintMaker.removeExisting = YES; 33 | block(constraintMaker); 34 | return [constraintMaker install]; 35 | } 36 | 37 | #pragma mark - NSLayoutAttribute properties 38 | 39 | - (MASViewAttribute *)mas_left { 40 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft]; 41 | } 42 | 43 | - (MASViewAttribute *)mas_top { 44 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop]; 45 | } 46 | 47 | - (MASViewAttribute *)mas_right { 48 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight]; 49 | } 50 | 51 | - (MASViewAttribute *)mas_bottom { 52 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom]; 53 | } 54 | 55 | - (MASViewAttribute *)mas_leading { 56 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading]; 57 | } 58 | 59 | - (MASViewAttribute *)mas_trailing { 60 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing]; 61 | } 62 | 63 | - (MASViewAttribute *)mas_width { 64 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth]; 65 | } 66 | 67 | - (MASViewAttribute *)mas_height { 68 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight]; 69 | } 70 | 71 | - (MASViewAttribute *)mas_centerX { 72 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX]; 73 | } 74 | 75 | - (MASViewAttribute *)mas_centerY { 76 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY]; 77 | } 78 | 79 | - (MASViewAttribute *)mas_baseline { 80 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline]; 81 | } 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute 84 | { 85 | return ^(NSLayoutAttribute attr) { 86 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr]; 87 | }; 88 | } 89 | 90 | #if TARGET_OS_IPHONE 91 | 92 | - (MASViewAttribute *)mas_leftMargin { 93 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin]; 94 | } 95 | 96 | - (MASViewAttribute *)mas_rightMargin { 97 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin]; 98 | } 99 | 100 | - (MASViewAttribute *)mas_topMargin { 101 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin]; 102 | } 103 | 104 | - (MASViewAttribute *)mas_bottomMargin { 105 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin]; 106 | } 107 | 108 | - (MASViewAttribute *)mas_leadingMargin { 109 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin]; 110 | } 111 | 112 | - (MASViewAttribute *)mas_trailingMargin { 113 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin]; 114 | } 115 | 116 | - (MASViewAttribute *)mas_centerXWithinMargins { 117 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins]; 118 | } 119 | 120 | - (MASViewAttribute *)mas_centerYWithinMargins { 121 | return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins]; 122 | } 123 | 124 | #endif 125 | 126 | #pragma mark - associated properties 127 | 128 | - (id)mas_key { 129 | return objc_getAssociatedObject(self, @selector(mas_key)); 130 | } 131 | 132 | - (void)setMas_key:(id)key { 133 | objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 134 | } 135 | 136 | #pragma mark - heirachy 137 | 138 | - (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view { 139 | MAS_VIEW *closestCommonSuperview = nil; 140 | 141 | MAS_VIEW *secondViewSuperview = view; 142 | while (!closestCommonSuperview && secondViewSuperview) { 143 | MAS_VIEW *firstViewSuperview = self; 144 | while (!closestCommonSuperview && firstViewSuperview) { 145 | if (secondViewSuperview == firstViewSuperview) { 146 | closestCommonSuperview = secondViewSuperview; 147 | } 148 | firstViewSuperview = firstViewSuperview.superview; 149 | } 150 | secondViewSuperview = secondViewSuperview.superview; 151 | } 152 | return closestCommonSuperview; 153 | } 154 | 155 | @end 156 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/View+MASShorthandAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+MASShorthandAdditions.h 3 | // Masonry 4 | // 5 | // Created by Jonas Budelmann on 22/07/13. 6 | // Copyright (c) 2013 Jonas Budelmann. All rights reserved. 7 | // 8 | 9 | #import "View+MASAdditions.h" 10 | 11 | #ifdef MAS_SHORTHAND 12 | 13 | /** 14 | * Shorthand view additions without the 'mas_' prefixes, 15 | * only enabled if MAS_SHORTHAND is defined 16 | */ 17 | @interface MAS_VIEW (MASShorthandAdditions) 18 | 19 | @property (nonatomic, strong, readonly) MASViewAttribute *left; 20 | @property (nonatomic, strong, readonly) MASViewAttribute *top; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *right; 22 | @property (nonatomic, strong, readonly) MASViewAttribute *bottom; 23 | @property (nonatomic, strong, readonly) MASViewAttribute *leading; 24 | @property (nonatomic, strong, readonly) MASViewAttribute *trailing; 25 | @property (nonatomic, strong, readonly) MASViewAttribute *width; 26 | @property (nonatomic, strong, readonly) MASViewAttribute *height; 27 | @property (nonatomic, strong, readonly) MASViewAttribute *centerX; 28 | @property (nonatomic, strong, readonly) MASViewAttribute *centerY; 29 | @property (nonatomic, strong, readonly) MASViewAttribute *baseline; 30 | @property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr); 31 | 32 | #if TARGET_OS_IPHONE 33 | 34 | @property (nonatomic, strong, readonly) MASViewAttribute *leftMargin; 35 | @property (nonatomic, strong, readonly) MASViewAttribute *rightMargin; 36 | @property (nonatomic, strong, readonly) MASViewAttribute *topMargin; 37 | @property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin; 38 | @property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin; 39 | @property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin; 40 | @property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins; 41 | @property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins; 42 | 43 | #endif 44 | 45 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block; 46 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block; 47 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block; 48 | 49 | @end 50 | 51 | #define MAS_ATTR_FORWARD(attr) \ 52 | - (MASViewAttribute *)attr { \ 53 | return [self mas_##attr]; \ 54 | } 55 | 56 | @implementation MAS_VIEW (MASShorthandAdditions) 57 | 58 | MAS_ATTR_FORWARD(top); 59 | MAS_ATTR_FORWARD(left); 60 | MAS_ATTR_FORWARD(bottom); 61 | MAS_ATTR_FORWARD(right); 62 | MAS_ATTR_FORWARD(leading); 63 | MAS_ATTR_FORWARD(trailing); 64 | MAS_ATTR_FORWARD(width); 65 | MAS_ATTR_FORWARD(height); 66 | MAS_ATTR_FORWARD(centerX); 67 | MAS_ATTR_FORWARD(centerY); 68 | MAS_ATTR_FORWARD(baseline); 69 | 70 | #if TARGET_OS_IPHONE 71 | 72 | MAS_ATTR_FORWARD(leftMargin); 73 | MAS_ATTR_FORWARD(rightMargin); 74 | MAS_ATTR_FORWARD(topMargin); 75 | MAS_ATTR_FORWARD(bottomMargin); 76 | MAS_ATTR_FORWARD(leadingMargin); 77 | MAS_ATTR_FORWARD(trailingMargin); 78 | MAS_ATTR_FORWARD(centerXWithinMargins); 79 | MAS_ATTR_FORWARD(centerYWithinMargins); 80 | 81 | #endif 82 | 83 | - (MASViewAttribute *(^)(NSLayoutAttribute))attribute { 84 | return [self mas_attribute]; 85 | } 86 | 87 | - (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { 88 | return [self mas_makeConstraints:block]; 89 | } 90 | 91 | - (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { 92 | return [self mas_updateConstraints:block]; 93 | } 94 | 95 | - (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { 96 | return [self mas_remakeConstraints:block]; 97 | } 98 | 99 | @end 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/ViewController+MASAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.h 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "MASUtilities.h" 10 | #import "MASConstraintMaker.h" 11 | #import "MASViewAttribute.h" 12 | 13 | #ifdef MAS_VIEW_CONTROLLER 14 | 15 | @interface MAS_VIEW_CONTROLLER (MASAdditions) 16 | 17 | /** 18 | * following properties return a new MASViewAttribute with appropriate UILa 8youtGuide and NSLayoutAttribute 19 | */ 20 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide; 21 | @property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide; 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /TBBStockView/Masonry/ViewController+MASAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MASAdditions.m 3 | // Masonry 4 | // 5 | // Created by Craig Siemens on 2015-06-23. 6 | // 7 | // 8 | 9 | #import "ViewController+MASAdditions.h" 10 | 11 | #ifdef MAS_VIEW_CONTROLLER 12 | 13 | @implementation MAS_VIEW_CONTROLLER (MASAdditions) 14 | 15 | - (MASViewAttribute *)mas_topLayoutGuide { 16 | return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom]; 17 | } 18 | 19 | - (MASViewAttribute *)mas_bottomLayoutGuide { 20 | return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop]; 21 | } 22 | 23 | @end 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /TBBStockView/Resource/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Resource/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Resource/images.bundle/dian_@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Resource/images.bundle/dian_@2x.png -------------------------------------------------------------------------------- /TBBStockView/Resource/images.bundle/dian_@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Resource/images.bundle/dian_@3x.png -------------------------------------------------------------------------------- /TBBStockView/Source/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Source/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Source/Common/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Source/Common/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Source/Common/Common.h: -------------------------------------------------------------------------------- 1 | // 2 | // Common.h 3 | // 美丽说DIY 4 | // 5 | // Created by 唐彬彬 on 17/5/21. 6 | // Copyright (c) 2017年 tbb. All rights reserved. 7 | // 8 | #import 9 | //#import "CommonNotifications.h" 10 | //#import "HLThirdPlatFormConfig.h" 11 | 12 | 13 | // 1.日志输出宏定义 14 | #ifdef DEBUG 15 | // 调试状态 16 | #define MyLog(...) NSLog(__VA_ARGS__) 17 | #else 18 | // 发布状态 19 | #define MyLog(...) 20 | #endif 21 | #ifdef DEBUG 22 | 23 | # define DLog(fmt, ...) {NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);} 24 | # define ELog(err) {if(err) DLog(@"%@", err)} 25 | #else 26 | # define DLog(...) 27 | # define ELog(err) 28 | #endif 29 | 30 | 31 | //iPhone6的屏幕宽度(点)---以iPhone6的屏幕为基准进行适配 32 | static const float kiPhone6Width = 375.f; 33 | //iPhone6的屏幕宽度(点)---以iPhone6的屏幕为基准进行适配 34 | #define kCurrentPhoneWidth ([UIScreen mainScreen].bounds.size.width) 35 | #define kCurrentPhoneHeight ([UIScreen mainScreen].bounds.size.height) 36 | 37 | 38 | //2.颜色 39 | #define kColorAlpha(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a] 40 | #define kColor(r,g,b) kColorAlpha(r,g,b,1) 41 | 42 | #define RandomColor [UIColor colorWithRed:arc4random_uniform(255)/155.0 green:arc4random_uniform(255)/155.0 blue:arc4random_uniform(255)/155.0 alpha:0.7] 43 | 44 | //3.设置弱引用 __weak 45 | #define WEAKINSTANCE(weakInstance,instance) __weak typeof(instance) weakInstance = instance; 46 | #define WS(weakSelf) WEAKINSTANCE(weakSelf,self) 47 | 48 | //4.设置绘制矩形上下文相关参数 49 | 50 | /** 51 | * 背景框的宽度 52 | */ 53 | static const float HYStockChartTimeLineGridWidth = 0.5; 54 | /** 55 | * TimeLineTopView的高度 56 | */ 57 | #define kTimeLineTopViewHeight 240.f 58 | /** 59 | * TimeLineBottomView的高度 60 | */ 61 | #define kTimeLineBottomViewHeight ((kTimeLineTopViewHeight-2*kHeightMargin)/2+kHeightMargin) 62 | /** 63 | 绘制矩形框范围与view横向间距 64 | */ 65 | #define kWidthMargin 10 66 | /** 67 | 绘制矩形框范围与view纵向间距 68 | */ 69 | #define kHeightMargin 20 70 | 71 | #define kViewHeight self.frame.size.height 72 | #define kViewWidth self.frame.size.width 73 | 74 | /** 75 | 绘制矩形框宽度 76 | */ 77 | #define kRectWidth (kViewWidth-2*kWidthMargin) 78 | /** 79 | 绘制矩形框高度 80 | */ 81 | #define kRectHeight (kViewHeight-2*kHeightMargin) 82 | /** 83 | 横坐标文字上下文范围 84 | */ 85 | #define kHorizontalTextRect CGRectMake(kWidthMargin,kRectHeight+kHeightMargin,kRectWidth, kHeightMargin) 86 | /** 87 | 纵坐标文字上下文范围TOP 88 | */ 89 | #define kVerticalTextTopRect CGRectMake(kWidthMargin,kHeightMargin,100.f, kRectHeight) 90 | /** 91 | 纵坐标文字上下文范围Center 92 | */ 93 | #define kVerticalTextCenterRect CGRectMake(kWidthMargin,kViewHeight/2-strSize.height/2,100.f, kRectHeight) 94 | /** 95 | 纵坐标文字上下文范围Bottom 96 | */ 97 | #define kVerticalTextTopBottomRect CGRectMake(kWidthMargin,kRectHeight+kHeightMargin-strSize.height,100.f, kRectHeight) 98 | 99 | #define kSlideWidth 40.f //滑块宽度 100 | #define kSlideHeigth 20.f //滑块高度 101 | -------------------------------------------------------------------------------- /TBBStockView/Source/Common/CommonEnum.h: -------------------------------------------------------------------------------- 1 | // 2 | // CommonEnum.h 3 | // zzhl 4 | // 5 | // Created by 唐彬彬 on 17/3/25. 6 | // Copyright © 2017年 TBB. All rights reserved. 7 | // 8 | 9 | // 放置公共枚举 10 | 11 | 12 | typedef NS_ENUM(NSInteger, kLineType) { 13 | /** 14 | * 实线 15 | */ 16 | kLineTypeFullLine = 1, 17 | /** 18 | * 虚线 19 | */ 20 | kLineTypeDottedline = 2, 21 | 22 | 23 | }; 24 | typedef NS_ENUM(NSInteger,kLineViewType) { 25 | 26 | /** 27 | * 分时图 28 | */ 29 | kLineViewTypeTime = 1, 30 | /** 31 | * k线图 32 | */ 33 | kLineViewTypek = 2, 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /TBBStockView/Source/Common/TBBStockView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBStockView.h 3 | // 4 | // Created by 唐彬彬 on 2017/7/9. 5 | // Copyright © 2017年 唐彬彬. All rights reserved. 6 | // 7 | 8 | #import "Common.h" 9 | #import "UIColor+HL.h" 10 | #import "TBBTimeLineView.h" 11 | #import "TBBTimeLineTopView.h" 12 | #import "TBBTimeLineBottom.h" 13 | #import "TBBTimeLineBottomView.h" 14 | #import "TBBTimeLineTopModel.h" 15 | #import "TBBTimeLineTopPointModel.h" 16 | #import "TBBTimeLineBottomPointModel.h" 17 | #import "TBBTimeLineTopTouchView.h" 18 | 19 | -------------------------------------------------------------------------------- /TBBStockView/Source/Common/UIColor+HL.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HL.h 3 | // zzhl 4 | // 5 | // Created by duyongjian on 16/1/15. 6 | // Copyright © 2016年 DuDavid. All rights reserved. 7 | // 8 | 9 | #import 10 | #define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A] 11 | #define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f] 12 | 13 | @interface UIColor(HL) 14 | + (UIColor *)colorWithHexString:(NSString *)color; 15 | 16 | //从十六进制字符串获取颜色, 17 | //color:支持@“#123456”、 @“0X123456”、 @“123456”三种格式 18 | + (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha; 19 | @end 20 | -------------------------------------------------------------------------------- /TBBStockView/Source/Common/UIColor+HL.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIColor+HL.m 3 | // zzhl 4 | // 5 | // Created by duyongjian on 16/1/15. 6 | // Copyright © 2016年 DuDavid. All rights reserved. 7 | // 8 | 9 | #import "UIColor+HL.h" 10 | 11 | @implementation UIColor(HL) 12 | 13 | + (UIColor *)colorWithHexString:(NSString *)color alpha:(CGFloat)alpha 14 | { 15 | //删除字符串中的空格 16 | NSString *cString = [[color stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; 17 | // String should be 6 or 8 characters 18 | if ([cString length] < 6) 19 | { 20 | return [UIColor clearColor]; 21 | } 22 | // strip 0X if it appears 23 | //如果是0x开头的,那么截取字符串,字符串从索引为2的位置开始,一直到末尾 24 | if ([cString hasPrefix:@"0X"]) 25 | { 26 | cString = [cString substringFromIndex:2]; 27 | } 28 | //如果是#开头的,那么截取字符串,字符串从索引为1的位置开始,一直到末尾 29 | if ([cString hasPrefix:@"#"]) 30 | { 31 | cString = [cString substringFromIndex:1]; 32 | } 33 | if ([cString length] != 6) 34 | { 35 | return [UIColor clearColor]; 36 | } 37 | 38 | // Separate into r, g, b substrings 39 | NSRange range; 40 | range.location = 0; 41 | range.length = 2; 42 | //r 43 | NSString *rString = [cString substringWithRange:range]; 44 | //g 45 | range.location = 2; 46 | NSString *gString = [cString substringWithRange:range]; 47 | //b 48 | range.location = 4; 49 | NSString *bString = [cString substringWithRange:range]; 50 | 51 | // Scan values 52 | unsigned int r, g, b; 53 | [[NSScanner scannerWithString:rString] scanHexInt:&r]; 54 | [[NSScanner scannerWithString:gString] scanHexInt:&g]; 55 | [[NSScanner scannerWithString:bString] scanHexInt:&b]; 56 | return [UIColor colorWithRed:((float)r / 255.0f) green:((float)g / 255.0f) blue:((float)b / 255.0f) alpha:alpha]; 57 | } 58 | 59 | //默认alpha值为1 60 | + (UIColor *)colorWithHexString:(NSString *)color 61 | { 62 | return [self colorWithHexString:color alpha:1.0f]; 63 | } 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBKLine/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Source/TBBKLine/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Source/TBBKLine/TBBKLineView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBKLineView.h 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TBBKLineView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBKLine/TBBKLineView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBKLineView.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBKLineView.h" 10 | 11 | @implementation TBBKLineView 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Source/TBBTimeLine/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottom.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottom.h 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface TBBTimeLineBottom : NSObject 12 | /**曲线点位置数据数组*/ 13 | @property(nonatomic,strong) NSArray *positionArr; 14 | 15 | @property(nonatomic,strong) CAShapeLayer *lineLayer; 16 | 17 | -(instancetype)initWithContext:(CGContextRef)context; 18 | -(void)drawTimeLineBottomWithPositionArray:(NSArray *)pointArray withLineColorArray:(NSArray *)colorArray andLineWidth:(CGFloat)lineWidth; 19 | @end 20 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottom.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottom.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineBottom.h" 10 | #import 11 | #import "UIColor+HL.h" 12 | #import "Common.h" 13 | #import "TBBTimeLineBottomPointModel.h" 14 | #import "TBBTimeLineTopPointModel.h" 15 | @interface TBBTimeLineBottom() 16 | @property(nonatomic,assign) CGContextRef context; 17 | @property(nonatomic,strong) UIColor *color;//矩形框颜色 18 | @end 19 | 20 | @implementation TBBTimeLineBottom 21 | -(instancetype)initWithContext:(CGContextRef)context { 22 | 23 | if (self = [super init]) { 24 | self.context = context; 25 | } 26 | return self; 27 | } 28 | 29 | -(void)drawTimeLineBottomWithPositionArray:(NSArray *)pointArray withLineColorArray:(NSArray *)colorArray andLineWidth:(CGFloat)lineWidth { 30 | 31 | if (pointArray.count <= 0) { 32 | return; 33 | }; 34 | UIBezierPath *path = [UIBezierPath bezierPath]; 35 | path.lineWidth = lineWidth; 36 | CGFloat maxY = kTimeLineBottomViewHeight-kHeightMargin; 37 | for (NSInteger i = 0; i < pointArray.count; i++) { 38 | //当前的点x 39 | TBBTimeLineBottomPointModel *positionModel = (TBBTimeLineBottomPointModel *)pointArray[i]; 40 | self.color = colorArray[i]; 41 | [self.color setStroke]; 42 | //绘制分时线条 43 | CGPoint startPoint = CGPointMake(positionModel.xPosition, maxY); 44 | CGPoint endPoint = CGPointMake(positionModel.xPosition, positionModel.yPosition); 45 | NSLog(@"statrPointX--%.2f---statrPointY--%.2f",startPoint.x,startPoint.y); 46 | NSLog(@"endPointX--%.2f---endPointY--%.2f",endPoint.x,endPoint.y); 47 | //画实体线 48 | const CGPoint solidPoints[] = {startPoint,endPoint}; 49 | CGContextStrokeLineSegments(self.context, solidPoints, 2); 50 | 51 | } 52 | 53 | [path stroke]; 54 | 55 | } 56 | @end 57 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottomPointModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottomPointModel.h 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface TBBTimeLineBottomPointModel : NSObject 12 | @property (nonatomic, assign) CGFloat xPosition; 13 | @property (nonatomic, assign) CGFloat yPosition; 14 | +(TBBTimeLineBottomPointModel *)initPositon:(CGFloat)xPositon yPosition:(CGFloat)yPosition; 15 | @end 16 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottomPointModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottomPointModel.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineBottomPointModel.h" 10 | 11 | @implementation TBBTimeLineBottomPointModel 12 | +(TBBTimeLineBottomPointModel *)initPositon:(CGFloat)xPositon yPosition:(CGFloat)yPosition { 13 | TBBTimeLineBottomPointModel *model = [[TBBTimeLineBottomPointModel alloc] init]; 14 | model.xPosition = xPositon; 15 | model.yPosition = yPosition; 16 | return model; 17 | } 18 | @end 19 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottomView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottomView.h 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TBBTimeLineBottomView : UIView 12 | @property (nonatomic, strong) NSArray *dataArr; 13 | @property (nonatomic, strong) NSArray *pointArray; 14 | @property (nonatomic, strong) NSArray *colorArray; 15 | -(NSArray *)caculatePosition; 16 | @end 17 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineBottomView/TBBTimeLineBottomView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineBottomView.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/8/7. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineBottomView.h" 10 | #import "Common.h" 11 | #import "CommonEnum.h" 12 | #import "UIColor+HL.h" 13 | #import "TBBTimeLineBottom.h" 14 | #import "TBBTimeLineTopModel.h" 15 | #import "TBBTimeLineBottomPointModel.h" 16 | @interface TBBTimeLineBottomView() 17 | @property (nonatomic ,assign) CGFloat maxVolume;//成交量 18 | @property (nonatomic ,assign) CGFloat minVolume; 19 | @property (nonatomic ,assign) kLineViewType lineViewType; 20 | @property (nonatomic ,strong) TBBTimeLineTopModel *timeLineTopModel; 21 | @property (nonatomic ,strong) TBBTimeLineBottomPointModel *timeLineBottomPointModel; 22 | @end 23 | 24 | @implementation TBBTimeLineBottomView 25 | 26 | -(instancetype)initWithFrame:(CGRect)frame { 27 | 28 | if (self = [super initWithFrame:frame]) { 29 | 30 | } 31 | return self; 32 | } 33 | 34 | -(void)drawRect:(CGRect)rect { 35 | 36 | [super drawRect:rect]; 37 | 38 | // //上下文区域 39 | CGContextRef context = UIGraphicsGetCurrentContext(); 40 | CGContextClearRect(context, rect); 41 | CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); 42 | CGContextFillRect(context, rect); 43 | //计算坐标 44 | [self caculatePosition]; 45 | //绘制坐标点 46 | TBBTimeLineBottom *timeLinebottom = [[TBBTimeLineBottom alloc]initWithContext:context]; 47 | CGFloat volumeLineWidth = (kCurrentPhoneWidth-2*kWidthMargin) / self.pointArray.count - 1.0; 48 | [timeLinebottom drawTimeLineBottomWithPositionArray:self.pointArray withLineColorArray:self.colorArray andLineWidth:volumeLineWidth]; 49 | //绘制背景矩形框 50 | [self drawGridBackground:context]; 51 | } 52 | 53 | #pragma mark - ****************使用C语言上下文绘制图形 54 | - (void)drawGridBackground:(CGContextRef)context { 55 | //绘制整体边框 56 | CGContextSetLineWidth(context, HYStockChartTimeLineGridWidth); 57 | CGContextSetStrokeColorWithColor(context,[UIColor colorWithHexString:@"999999"].CGColor); 58 | CGContextStrokeRect(context, CGRectMake(kWidthMargin, 0, (kViewWidth-2*kWidthMargin) , kViewHeight-kHeightMargin)); 59 | /** 60 | 使用CGContextRef绘制图形,如果将实线放入循环中与虚线一起绘制,绘制时在同一个上下文重用了上次绘制的样式会出现错乱的bug 61 | */ 62 | //绘制中间的竖实线 63 | [self lineType:kLineTypeFullLine drawline:context startPoint:CGPointMake(kViewWidth / 2,0) stopPoint:CGPointMake(kViewWidth / 2, kViewHeight-kHeightMargin) color:[UIColor colorWithHexString:@"999999"] lineWidth:0.5]; 64 | //绘制横实线 65 | [self lineType:kLineTypeFullLine drawline:context startPoint:CGPointMake(kWidthMargin,(kTimeLineBottomViewHeight-kHeightMargin)/2) stopPoint:CGPointMake(kViewWidth-kWidthMargin, (kTimeLineBottomViewHeight-kHeightMargin)/2) color:[UIColor colorWithHexString:@"999999"] lineWidth:0.5]; 66 | //绘制虚线 67 | for (int i=2; i<5; i++) { 68 | if (i == 3 ) { 69 | 70 | }else{ 71 | 72 | // 绘制竖着的虚线 73 | [self lineType:kLineTypeDottedline drawline:context startPoint:CGPointMake(kWidthMargin+kRectWidth / 4*(i-1),0) stopPoint:CGPointMake(kWidthMargin+kRectWidth / 4*(i-1),kViewHeight-kHeightMargin) color:[UIColor colorWithHexString:@"999999"] lineWidth:0.5]; 74 | 75 | } 76 | 77 | } 78 | 79 | 80 | } 81 | #pragma mark - **************** 使用CGContextRef绘制中间的虚实线 82 | 83 | - (void)lineType:(kLineType)lineType drawline:(CGContextRef)context 84 | startPoint:(CGPoint)startPoint 85 | stopPoint:(CGPoint)stopPoint 86 | color:(UIColor *)color 87 | lineWidth:(CGFloat)lineWitdth 88 | { 89 | CGContextSetStrokeColorWithColor(context, color.CGColor); 90 | CGContextSetLineWidth(context, lineWitdth); 91 | CGContextMoveToPoint(context, startPoint.x, startPoint.y); 92 | CGContextAddLineToPoint(context, stopPoint.x,stopPoint.y); 93 | if (lineType == kLineTypeDottedline) { 94 | //设置虚线排列的宽度间隔:下面的arr中的数字表示先绘制5个点再绘制1个点 95 | CGFloat arr[] = {6,1}; 96 | //下面最后一个参数“1”代表排列的个数。 97 | CGContextSetLineDash(context, 0, arr, 2); 98 | } 99 | CGContextStrokePath(context); 100 | 101 | } 102 | 103 | //计算点的位置坐标 104 | -(NSArray *)caculatePosition { 105 | WS(ws); 106 | _lineViewType = kLineViewTypeTime; 107 | CGFloat minY = 0; 108 | CGFloat maxY = kTimeLineBottomViewHeight-kHeightMargin; 109 | 110 | //1.算y轴的单元值 111 | if (_lineViewType == kLineViewTypeTime) { 112 | //x轴每一分钟一个点,9:30到11:30,13:00到15:00共计240分钟 113 | //每一个横坐标点所占单元 114 | CGFloat unitX = kRectWidth/240.f; 115 | NSLog(@"%f",unitX); 116 | //计算y轴每一个点所占单元 117 | TBBTimeLineTopModel *firstModel = [self.dataArr firstObject]; 118 | self.maxVolume = firstModel.volume; 119 | self.minVolume = firstModel.volume; 120 | 121 | NSMutableArray *pointArr = [NSMutableArray array]; 122 | if (self.dataArr.count > 0) { 123 | [self.dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 124 | TBBTimeLineTopModel *lineModel = (TBBTimeLineTopModel *)obj; 125 | if (lineModel.volume < ws.minVolume) { 126 | ws.minVolume = lineModel.volume; 127 | }else if (lineModel.volume > ws.maxVolume) { 128 | ws.maxVolume = lineModel.volume; 129 | } 130 | }]; 131 | NSLog(@"minVolume: %.2f---maxVolume: %.2f",self.minVolume,self.maxVolume); 132 | CGFloat unitY = (ws.maxVolume - ws.minVolume)/(maxY-minY); 133 | if (!self.dataArr && self.dataArr == nil) { 134 | return nil; 135 | }else { 136 | 137 | //遍历当前的点坐标放入数组 138 | [self.dataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { 139 | TBBTimeLineTopModel *lineModel = (TBBTimeLineTopModel *)obj; 140 | CGFloat x = idx*unitX+kWidthMargin; 141 | //y值考虑最大可能超出,加上绘制的线宽和矩形框的线宽 142 | CGFloat y = maxY-HYStockChartTimeLineGridWidth-(lineModel.volume - self.minVolume)/unitY; 143 | TBBTimeLineBottomPointModel *pointModel = [TBBTimeLineBottomPointModel initPositon:x yPosition:y]; 144 | [pointArr addObject:pointModel]; 145 | }]; 146 | 147 | ws.pointArray = pointArr; 148 | } 149 | } 150 | return ws.pointArray; 151 | } 152 | 153 | return ws.pointArray; 154 | } 155 | @end 156 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/.DS_Store -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTop.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineTop.h 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 绘制分时线与背景的类 8 | 9 | #import 10 | #import 11 | @interface TBBTimeLineTop : NSObject 12 | /**曲线点位置数据数组*/ 13 | @property(nonatomic,strong) NSArray *positionArr; 14 | 15 | @property(nonatomic,strong) CAShapeLayer *lineLayer; 16 | 17 | -(instancetype)initWithContext:(CGContextRef)context; 18 | -(void)drawTimeLineTopWithPositionArray:(NSArray *)pointArray withLineColor:(UIColor *)lineColor andLineWidth:(CGFloat)lineWidth; 19 | @end 20 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTop.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLine.m 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineTop.h" 10 | #import "UIColor+HL.h" 11 | #import "Common.h" 12 | #import "TBBTimeLineTopModel.h" 13 | #import "TBBTimeLineTopPointModel.h" 14 | 15 | 16 | 17 | @interface TBBTimeLineTop () 18 | @property(nonatomic,assign) CGContextRef context; 19 | 20 | @end 21 | @implementation TBBTimeLineTop 22 | 23 | -(instancetype)initWithContext:(CGContextRef)context 24 | { 25 | self = [super init]; 26 | if (self) { 27 | self.context = context; 28 | } 29 | return self; 30 | } 31 | 32 | /** 33 | 获取点坐标数组进行绘制 34 | 35 | @param pointArray 点坐标数组 36 | @param lineColor 线的颜色 37 | @param lineWidth 线宽 38 | */ 39 | -(void)drawTimeLineTopWithPositionArray:(NSArray *)pointArray withLineColor:(UIColor *)lineColor andLineWidth:(CGFloat)lineWidth{ 40 | if (pointArray.count <= 0) { 41 | return; 42 | }; 43 | UIBezierPath *path = [UIBezierPath bezierPath]; 44 | UIBezierPath *path1 = [UIBezierPath bezierPath]; 45 | path.lineWidth = lineWidth; 46 | [lineColor setStroke]; 47 | 48 | for (NSInteger i = 0; i < pointArray.count; i++) { 49 | //当前的点 50 | TBBTimeLineTopPointModel *positionModel = (TBBTimeLineTopPointModel *)pointArray[i]; 51 | //当前点是否包含X,Y 52 | if (i == 0) { 53 | //移动到当前点 54 | [path moveToPoint:CGPointMake(positionModel.xPosition, positionModel.yPosition)]; 55 | [path1 moveToPoint:CGPointMake(positionModel.xPosition, positionModel.yPosition)]; 56 | } 57 | 58 | if (i+1 < pointArray.count) { 59 | TBBTimeLineTopPointModel *nextPositionModel = (TBBTimeLineTopPointModel *)pointArray[i+1]; 60 | //绘制分时线条 61 | [path addLineToPoint:CGPointMake(nextPositionModel.xPosition, nextPositionModel.yPosition)]; 62 | [path1 addLineToPoint:CGPointMake(nextPositionModel.xPosition, nextPositionModel.yPosition)]; 63 | NSLog(@"%f,%f",positionModel.xPosition,positionModel.yPosition); 64 | } 65 | 66 | } 67 | [path stroke]; 68 | //绘制背景 69 | TBBTimeLineTopPointModel *firstObj = (TBBTimeLineTopPointModel *)pointArray.firstObject; 70 | TBBTimeLineTopPointModel *lastObj = (TBBTimeLineTopPointModel *)pointArray.lastObject; 71 | [path1 addLineToPoint:CGPointMake(lastObj.xPosition, kTimeLineTopViewHeight-kHeightMargin)]; 72 | [path1 addLineToPoint:CGPointMake(kWidthMargin, kTimeLineTopViewHeight-kHeightMargin)]; 73 | [path1 addLineToPoint:CGPointMake(kWidthMargin, firstObj.yPosition)]; 74 | [[UIColor colorWithHexString:@"ACD6FF"] setFill]; 75 | [path1 fill]; 76 | 77 | } 78 | 79 | 80 | 81 | @end 82 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineModel.h 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // assignright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | //分时图模型 12 | @interface TBBTimeLineTopModel : NSObject 13 | @property (nonatomic, copy) NSString *data_time_stamp; 14 | @property (nonatomic, copy) NSString *currtTime; 15 | @property (nonatomic, assign) CGFloat preClosePx; 16 | @property (nonatomic, assign) CGFloat avgPirce; 17 | @property (nonatomic, assign) CGFloat lastPirce; 18 | @property (nonatomic, assign) CGFloat totalVolume; 19 | @property (nonatomic, assign) CGFloat volume; 20 | @property (nonatomic, assign) CGFloat trade; 21 | @property (nonatomic, copy) NSString *rate; 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLineModel.m 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineTopModel.h" 10 | 11 | @implementation TBBTimeLineTopModel 12 | 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopPointModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLinePointModel.h 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | @interface TBBTimeLineTopPointModel : NSObject 12 | @property (nonatomic, assign) CGFloat xPosition; 13 | @property (nonatomic, assign) CGFloat yPosition; 14 | +(TBBTimeLineTopPointModel *)initPositon:(CGFloat)xPositon yPosition:(CGFloat)yPosition; 15 | @end 16 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopPointModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTimeLinePointModel.m 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/5/28. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "TBBTimeLineTopPointModel.h" 10 | @implementation TBBTimeLineTopPointModel 11 | +(TBBTimeLineTopPointModel *)initPositon:(CGFloat)xPositon yPosition:(CGFloat)yPosition { 12 | TBBTimeLineTopPointModel *model = [[TBBTimeLineTopPointModel alloc] init]; 13 | model.xPosition = xPositon; 14 | model.yPosition = yPosition; 15 | return model; 16 | } 17 | @end 18 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopTouchView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TBBTouchView.h 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/7/3. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "TBBTimeLineTopModel.h" 11 | @interface TBBTimeLineTopTouchView : UIView 12 | @property (nonatomic, strong) NSArray *topViewPointArray; 13 | @property (nonatomic, strong) NSArray *bottomViewPointArray; 14 | @property (nonatomic, strong) NSArray *dataArray; 15 | - (instancetype)initWithFrame:(CGRect)frame withTopViewPointArray:(NSArray *)topViewPointArray BottomViewPointArray:(NSArray *)bottomViewPointArray; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineTopView/TBBTimeLineTopView.h: -------------------------------------------------------------------------------- 1 | // 2 | // HLLineChartView.h 3 | // CAShapeLayer 4 | // 5 | // Created by 唐彬彬 on 16/5/29. 6 | // Copyright © 2016年 唐彬彬. All rights reserved. 7 | // 分时图上面的view 8 | 9 | #import 10 | 11 | @interface TBBTimeLineTopView : UIView 12 | @property (nonatomic, strong) NSArray *dataArr; 13 | @property (nonatomic, strong) NSArray *colorArray; //颜色数组 14 | @property (nonatomic, strong) NSArray *pointArray; 15 | -(instancetype)initWithFrame:(CGRect)frame; 16 | -(NSArray *)caculatePosition; 17 | @end 18 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TimeLineView.h 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/7/2. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "TBBTimeLineTopView.h" 11 | #import "TBBTimeLineBottomView.h" 12 | #import "TBBTimeLineTopTouchView.h" 13 | @interface TBBTimeLineView : UIView 14 | @property (nonatomic, strong) TBBTimeLineTopView *topView; 15 | @property (nonatomic, strong) TBBTimeLineTopTouchView *touchView; 16 | @property (nonatomic, strong) TBBTimeLineBottomView *bottomView; 17 | @property (nonatomic, strong) NSArray *dataArray; 18 | @property (nonatomic, strong) NSArray *topPointArr;//上面视图点的坐标数组 19 | @property (nonatomic, strong) NSArray *bottomPointArr;//下面视图点的坐标数组 20 | -(instancetype)initWithFrame:(CGRect)frame withDataArr:(NSArray *)dataArray; 21 | @end 22 | -------------------------------------------------------------------------------- /TBBStockView/Source/TBBTimeLine/TBBTimeLineView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TimeLineView.m 3 | // TBB-Kline 4 | // 5 | // Created by 唐彬彬 on 2017/7/2. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 分时图整个view 8 | 9 | #import "Common.h" 10 | #import "TBBTimeLineView.h" 11 | #import "TBBTimeLineTopView.h" 12 | #import "TBBTimeLineTopPointModel.h" 13 | #import "TBBTimeLineTopView.h" 14 | #import "TBBTimeLineTopTouchView.h" 15 | @interface TBBTimeLineView () 16 | @property (nonatomic, strong) CAShapeLayer *xLineLayer; 17 | @property (nonatomic, strong) CAShapeLayer *yLineLayer; 18 | @property (nonatomic,assign) NSInteger curentModelIndex; 19 | @property (nonatomic, strong) UILongPressGestureRecognizer *longPressGesture; 20 | @end 21 | @implementation TBBTimeLineView 22 | -(NSArray *)dataArray { 23 | 24 | if (!_dataArray) { 25 | _dataArray = [NSArray array]; 26 | } 27 | return _dataArray; 28 | } 29 | -(instancetype)initWithFrame:(CGRect)frame withDataArr:(NSArray *)dataArray{ 30 | if (self = [super initWithFrame:frame]) { 31 | self.dataArray = dataArray; 32 | self.backgroundColor = [UIColor whiteColor]; 33 | [self setupPages]; 34 | 35 | } 36 | return self; 37 | } 38 | 39 | -(void)setupPages { 40 | self.topView = [[TBBTimeLineTopView alloc]initWithFrame:CGRectMake(0, 0, kCurrentPhoneWidth, kTimeLineTopViewHeight)]; 41 | self.topView.dataArr = self.dataArray; 42 | self.topPointArr = [self.topView caculatePosition]; 43 | [self addSubview:self.topView]; 44 | self.bottomView = [[TBBTimeLineBottomView alloc]initWithFrame:CGRectMake(0, kTimeLineTopViewHeight, kCurrentPhoneWidth, kTimeLineBottomViewHeight)]; 45 | self.bottomView.colorArray = self.topView.colorArray; 46 | self.bottomView.dataArr = self.dataArray; 47 | self.bottomPointArr = [self.bottomView caculatePosition]; 48 | [self addSubview:self.bottomView]; 49 | self.touchView = [[TBBTimeLineTopTouchView alloc]initWithFrame:CGRectMake(0, 0, kCurrentPhoneWidth, 400.f) withTopViewPointArray:self.topPointArr BottomViewPointArray:self.bottomPointArr]; 50 | self.touchView.dataArray = self.dataArray; 51 | [self addSubview:self.touchView]; 52 | } 53 | 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /TBBStockView/TBBStockView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HLTangbinbin/TBBStockView/e64d71a42e5af416ddc158b67276698135a353f0/TBBStockView/TBBStockView.gif -------------------------------------------------------------------------------- /TBBStockView/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // TBBLineChartView 4 | // 5 | // Created by 唐彬彬 on 2017/7/8. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /TBBStockView/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // TBBLineChartView 4 | // 5 | // Created by 唐彬彬 on 2017/7/8. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BtnView.h" 11 | #import "TBBTimeLineTopView.h" 12 | #import "Masonry.h" 13 | #import "Common.h" 14 | #import "UIColor+HL.h" 15 | #import "TBBTimeLineTop.h" 16 | #import "TBBTimeLineTopModel.h" 17 | #import "TBBTimeLineView.h" 18 | #define KScreenWidth [UIScreen mainScreen].bounds.size.width 19 | #define KScreenHeight [UIScreen mainScreen].bounds.size.height 20 | #define WEAKINSTANCE(weakInstance,instance) __weak typeof(instance) weakInstance = instance; 21 | #define WS(weakSelf) WEAKINSTANCE(weakSelf,self) 22 | 23 | @interface ViewController () 24 | @property (nonatomic ,strong) BtnView *btnview; 25 | @property (nonatomic ,strong) TBBTimeLineView *lineView; 26 | @property (nonatomic ,strong) NSArray *dataArr; 27 | @end 28 | 29 | @implementation ViewController 30 | 31 | - (void)viewDidLoad { 32 | [super viewDidLoad]; 33 | self.view.backgroundColor = [UIColor whiteColor]; 34 | NSArray *array = @[@"分时",@"日K",@"周K",@"月K",@"分钟"]; 35 | //按钮选择 36 | BtnView *btnView = [[BtnView alloc]initWithFrame:CGRectMake(0, 64.0f, KScreenWidth, 50.0f) titleArray:array selectedColor:[UIColor redColor] normalColor:[UIColor blackColor] titleSize:(__bridge CGSize *)([UIFont systemFontOfSize:13])]; 37 | self.btnview = btnView; 38 | [self.view addSubview:btnView]; 39 | 40 | NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]; 41 | NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path]; 42 | NSArray *datas = [dict objectForKey:@"data3"]; 43 | NSMutableArray *dataArray = [NSMutableArray array]; 44 | 45 | for (NSDictionary *dic in datas) { 46 | TBBTimeLineTopModel *model = [[TBBTimeLineTopModel alloc]init]; 47 | model.data_time_stamp = dict[@"data_time_stamp"]; 48 | model.currtTime = dic[@"curr_time"]; 49 | model.preClosePx = [dic[@"pre_close_px"] floatValue] ; 50 | model.avgPirce = [dic[@"avg_pirce"] floatValue]; 51 | model.lastPirce = [dic[@"last_px"]floatValue]; 52 | model.volume = [dic[@"last_volume_trade"]floatValue]; 53 | model.rate = dic[@"rise_and_fall_rate"]; 54 | [dataArray addObject:model]; 55 | } 56 | self.dataArr = dataArray; 57 | TBBTimeLineView *lineView = [[TBBTimeLineView alloc]initWithFrame:CGRectMake(0, 114.0f, KScreenWidth, kTimeLineTopViewHeight+kTimeLineBottomViewHeight) withDataArr:self.dataArr]; 58 | self.lineView = lineView; 59 | [self.view addSubview:self.lineView]; 60 | 61 | WS(ws); 62 | //点击不同的按钮根据tag添加不同的视图 63 | [self.btnview addSubviewWithBlock:^(NSInteger tag) { 64 | if (tag == 100) { 65 | for (UIView *views in [ws.lineView subviews]) { 66 | [views removeFromSuperview]; 67 | } 68 | [ws.lineView addSubview:ws.lineView.topView]; 69 | [ws.lineView addSubview:ws.lineView.bottomView]; 70 | [ws.lineView addSubview:ws.lineView.touchView]; 71 | }else if (tag == 101){ 72 | for (UIView *views in [ws.lineView subviews]) { 73 | [views removeFromSuperview]; 74 | } 75 | 76 | }else { 77 | 78 | for (UIView *views in [ws.lineView subviews]) { 79 | [views removeFromSuperview]; 80 | } 81 | } 82 | }]; 83 | 84 | 85 | } 86 | 87 | 88 | 89 | 90 | @end 91 | -------------------------------------------------------------------------------- /TBBStockView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TBBStockView 4 | // 5 | // Created by 唐彬彬 on 2017/7/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TBBStockViewTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TBBStockViewTests/TBBStockViewTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBStockViewTests.m 3 | // TBBStockViewTests 4 | // 5 | // Created by 唐彬彬 on 2017/7/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TBBStockViewTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TBBStockViewTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /TBBStockViewUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /TBBStockViewUITests/TBBStockViewUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // TBBStockViewUITests.m 3 | // TBBStockViewUITests 4 | // 5 | // Created by 唐彬彬 on 2017/7/9. 6 | // Copyright © 2017年 唐彬彬. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TBBStockViewUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation TBBStockViewUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------