Showing preview only (1,063K chars total). Download the full file or copy to clipboard to get everything.
Repository: lovesunstar/stkitdemo
Branch: master
Commit: a844ecad995f
Files: 341
Total size: 42.0 MB
Directory structure:
gitextract_9zbrd07j/
├── .gitignore
├── README.md
├── STKitDemo/
│ ├── Classes/
│ │ ├── 3rdLibs/
│ │ │ ├── MZCroppableView/
│ │ │ │ ├── MZCroppableView.h
│ │ │ │ ├── MZCroppableView.m
│ │ │ │ ├── UIBezierPath-Points.h
│ │ │ │ └── UIBezierPath-Points.m
│ │ │ ├── PingTester/
│ │ │ │ ├── SimplePing.h
│ │ │ │ └── SimplePing.m
│ │ │ └── SphereView/
│ │ │ ├── PFGoldenSectionSpiral.h
│ │ │ ├── PFGoldenSectionSpiral.m
│ │ │ ├── ZYQSphereView.h
│ │ │ └── ZYQSphereView.m
│ │ ├── BaseUI/
│ │ │ ├── STAlertView.h
│ │ │ ├── STAlertView.m
│ │ │ ├── STDCardTransitionDelegate.h
│ │ │ ├── STDCardTransitionDelegate.m
│ │ │ ├── STDCoreDataManager.h
│ │ │ ├── STDCoreDataManager.m
│ │ │ ├── STDLoadingView.h
│ │ │ ├── STDLoadingView.m
│ │ │ ├── STDRefreshControl.h
│ │ │ ├── STDRefreshControl.m
│ │ │ ├── STDRotateTransitionDelegate.h
│ │ │ ├── STDRotateTransitionDelegate.m
│ │ │ ├── STDScrollViewController.h
│ │ │ ├── STDScrollViewController.m
│ │ │ ├── STDTabBarController.h
│ │ │ ├── STDTabBarController.m
│ │ │ ├── STDTableViewController.h
│ │ │ ├── STDTableViewController.m
│ │ │ ├── STDTextTableViewController.h
│ │ │ ├── STDTextTableViewController.m
│ │ │ ├── STDTransitionDelegate.h
│ │ │ ├── STDTransitionDelegate.m
│ │ │ ├── STDViewController.h
│ │ │ ├── STDViewController.m
│ │ │ ├── STDropMenuView.h
│ │ │ ├── STDropMenuView.m
│ │ │ ├── STMenuView.h
│ │ │ ├── STMenuView.m
│ │ │ └── SideBar/
│ │ │ ├── STDLeftViewController.h
│ │ │ ├── STDLeftViewController.m
│ │ │ ├── STDSideBarController.h
│ │ │ └── STDSideBarController.m
│ │ ├── Modules/
│ │ │ ├── Components/
│ │ │ │ ├── Image/
│ │ │ │ │ ├── STDCardViewController.h
│ │ │ │ │ ├── STDCardViewController.m
│ │ │ │ │ ├── STDFeedCell.h
│ │ │ │ │ ├── STDFeedCell.m
│ │ │ │ │ ├── STDFeedImageView.h
│ │ │ │ │ ├── STDFeedImageView.m
│ │ │ │ │ ├── STDFeedItem.h
│ │ │ │ │ ├── STDFeedItem.m
│ │ │ │ │ ├── STDFeedViewController.h
│ │ │ │ │ ├── STDFeedViewController.m
│ │ │ │ │ ├── STDownloadViewController.h
│ │ │ │ │ └── STDownloadViewController.m
│ │ │ │ ├── STDImageBlurViewController.h
│ │ │ │ ├── STDImageBlurViewController.m
│ │ │ │ ├── STDNavigationTestViewController.h
│ │ │ │ ├── STDNavigationTestViewController.m
│ │ │ │ ├── STDScrollViewController.h
│ │ │ │ ├── STDScrollViewController.m
│ │ │ │ ├── STDemoViewController.h
│ │ │ │ ├── STDemoViewController.m
│ │ │ │ └── TextLayout/
│ │ │ │ ├── STDAboutViewController.h
│ │ │ │ ├── STDAboutViewController.m
│ │ │ │ ├── STDLinkViewController.h
│ │ │ │ ├── STDLinkViewController.m
│ │ │ │ ├── STDTextViewController.h
│ │ │ │ └── STDTextViewController.m
│ │ │ ├── DesignPatterns/
│ │ │ │ ├── Creational/
│ │ │ │ │ ├── STDAbstractFactory.h
│ │ │ │ │ ├── STDAbstractFactory.m
│ │ │ │ │ ├── STDBuilder.h
│ │ │ │ │ ├── STDBuilder.m
│ │ │ │ │ ├── STDFactoryMethod.h
│ │ │ │ │ ├── STDFactoryMethod.m
│ │ │ │ │ ├── STDPrototype.h
│ │ │ │ │ ├── STDPrototype.m
│ │ │ │ │ ├── STDSingleton.h
│ │ │ │ │ └── STDSingleton.m
│ │ │ │ ├── STDesignPatterns.h
│ │ │ │ └── Structural/
│ │ │ │ ├── STDAdapter.h
│ │ │ │ ├── STDAdapter.m
│ │ │ │ ├── STDBridge.h
│ │ │ │ ├── STDBridge.m
│ │ │ │ ├── STDFacade.h
│ │ │ │ ├── STDFacade.m
│ │ │ │ ├── STDProxy.h
│ │ │ │ └── STDProxy.m
│ │ │ ├── STDSideBar/
│ │ │ │ ├── STDMapViewController.h
│ │ │ │ ├── STDMapViewController.m
│ │ │ │ └── STDMapViewController.xib
│ │ │ ├── STDStartViewController.h
│ │ │ ├── STDStartViewController.m
│ │ │ ├── Services/
│ │ │ │ ├── Algorithm/
│ │ │ │ │ ├── STACodeViewController.h
│ │ │ │ │ ├── STACodeViewController.m
│ │ │ │ │ ├── STAHanoiOperation.h
│ │ │ │ │ ├── STAHanoiOperation.m
│ │ │ │ │ ├── STAHanoiView.h
│ │ │ │ │ ├── STAHanoiView.m
│ │ │ │ │ ├── STAHanoiViewController.h
│ │ │ │ │ ├── STAHanoiViewController.m
│ │ │ │ │ ├── STARootViewController.h
│ │ │ │ │ ├── STARootViewController.m
│ │ │ │ │ ├── STASortDefines.h
│ │ │ │ │ ├── STASortOperation.h
│ │ │ │ │ ├── STASortOperation.m
│ │ │ │ │ ├── STASortView.h
│ │ │ │ │ ├── STASortView.m
│ │ │ │ │ ├── STASortViewController.h
│ │ │ │ │ └── STASortViewController.m
│ │ │ │ ├── BookReader/
│ │ │ │ │ ├── STDBookViewController.h
│ │ │ │ │ ├── STDBookViewController.m
│ │ │ │ │ ├── STDReaderViewController.h
│ │ │ │ │ ├── STDReaderViewController.m
│ │ │ │ │ ├── STRichView.h
│ │ │ │ │ ├── STRichView.m
│ │ │ │ │ └── book.txt
│ │ │ │ ├── CoreData/
│ │ │ │ │ ├── Entity/
│ │ │ │ │ │ ├── STDEntityDefines.h
│ │ │ │ │ │ ├── STDImage.h
│ │ │ │ │ │ ├── STDImage.m
│ │ │ │ │ │ ├── STDMessage.h
│ │ │ │ │ │ ├── STDMessage.m
│ │ │ │ │ │ ├── STDSession.h
│ │ │ │ │ │ ├── STDSession.m
│ │ │ │ │ │ ├── STDUser.h
│ │ │ │ │ │ └── STDUser.m
│ │ │ │ │ ├── STDBaseChatCell.h
│ │ │ │ │ ├── STDBaseChatCell.m
│ │ │ │ │ ├── STDChat.h
│ │ │ │ │ ├── STDChat.m
│ │ │ │ │ ├── STDChatInputView.h
│ │ │ │ │ ├── STDChatInputView.m
│ │ │ │ │ ├── STDChatViewController.h
│ │ │ │ │ ├── STDChatViewController.m
│ │ │ │ │ ├── STDImageChatCell.h
│ │ │ │ │ ├── STDImageChatCell.m
│ │ │ │ │ ├── STDModel.xcdatamodeld/
│ │ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ │ ├── STDModel 2.xcdatamodel/
│ │ │ │ │ │ │ └── contents
│ │ │ │ │ │ └── STDModel.xcdatamodel/
│ │ │ │ │ │ └── contents
│ │ │ │ │ ├── STDTextChatCell.h
│ │ │ │ │ └── STDTextChatCell.m
│ │ │ │ ├── Recorder/
│ │ │ │ │ ├── SCSiriWaveformView.h
│ │ │ │ │ ├── SCSiriWaveformView.m
│ │ │ │ │ ├── STDAboutAudioViewController.h
│ │ │ │ │ ├── STDAboutAudioViewController.m
│ │ │ │ │ ├── STDRecordViewController.h
│ │ │ │ │ ├── STDRecordViewController.m
│ │ │ │ │ ├── STWaveBarView.h
│ │ │ │ │ └── STWaveBarView.m
│ │ │ │ ├── STDServiceViewController.h
│ │ │ │ └── STDServiceViewController.m
│ │ │ └── Settings/
│ │ │ ├── Debug/
│ │ │ │ ├── STDAuthorization.h
│ │ │ │ ├── STDAuthorization.m
│ │ │ │ ├── STDDebugPingViewController.h
│ │ │ │ ├── STDDebugPingViewController.m
│ │ │ │ ├── STDLocationPickerController.h
│ │ │ │ ├── STDLocationPickerController.m
│ │ │ │ ├── STDPingServices.h
│ │ │ │ ├── STDPingServices.m
│ │ │ │ ├── STDebugFoundation.h
│ │ │ │ └── STDebugFoundation.m
│ │ │ ├── STDButton.h
│ │ │ ├── STDButton.m
│ │ │ ├── STDFontViewController.h
│ │ │ ├── STDFontViewController.m
│ │ │ ├── STDMoreViewController.h
│ │ │ ├── STDMoreViewController.m
│ │ │ ├── STDNavigationSettingViewController.h
│ │ │ ├── STDNavigationSettingViewController.m
│ │ │ ├── STDNavigationSettingViewController.xib
│ │ │ ├── STDSettingViewController.h
│ │ │ └── STDSettingViewController.m
│ │ └── STKit.framework/
│ │ ├── Headers/
│ │ │ ├── Foundation+STKit.h
│ │ │ ├── NSData+STGZip.h
│ │ │ ├── STAESCryptor.h
│ │ │ ├── STAlbumManager.h
│ │ │ ├── STApplicationContext.h
│ │ │ ├── STAudioCenter.h
│ │ │ ├── STAudioRecorder.h
│ │ │ ├── STButton.h
│ │ │ ├── STCategories.h
│ │ │ ├── STCollectionViewFlowLayout.h
│ │ │ ├── STControlDefines.h
│ │ │ ├── STCoreDataManager.h
│ │ │ ├── STDefines.h
│ │ │ ├── STGIFGenerator.h
│ │ │ ├── STHTTPConfiguration.h
│ │ │ ├── STHTTPNetwork.h
│ │ │ ├── STHTTPOperation.h
│ │ │ ├── STHTTPRequest.h
│ │ │ ├── STImage.h
│ │ │ ├── STImageCache.h
│ │ │ ├── STImageCollectionView.h
│ │ │ ├── STImageLoader.h
│ │ │ ├── STImagePickerController.h
│ │ │ ├── STImagePresent.h
│ │ │ ├── STImageScrollView.h
│ │ │ ├── STImageView.h
│ │ │ ├── STImageViewController.h
│ │ │ ├── STIndicatorView.h
│ │ │ ├── STJavaScriptBridge.h
│ │ │ ├── STKeychain.h
│ │ │ ├── STKit.h
│ │ │ ├── STLabel.h
│ │ │ ├── STLinkLabel.h
│ │ │ ├── STLocationManager.h
│ │ │ ├── STModel.h
│ │ │ ├── STModelViewController.h
│ │ │ ├── STNavigationBar.h
│ │ │ ├── STNavigationController.h
│ │ │ ├── STNetworkConfiguration.h
│ │ │ ├── STNotificationWindow.h
│ │ │ ├── STObject.h
│ │ │ ├── STPaginationControl.h
│ │ │ ├── STPayManager.h
│ │ │ ├── STPayViewController.h
│ │ │ ├── STPersistence.h
│ │ │ ├── STPopoverView.h
│ │ │ ├── STRSACryptor.h
│ │ │ ├── STRateControl.h
│ │ │ ├── STReachability.h
│ │ │ ├── STRefreshControl.h
│ │ │ ├── STRoundProgressView.h
│ │ │ ├── STScrollDirector.h
│ │ │ ├── STSearchBar.h
│ │ │ ├── STSearchDisplayController.h
│ │ │ ├── STShadow.h
│ │ │ ├── STSideBarController.h
│ │ │ ├── STStringTokenizer.h
│ │ │ ├── STTabBar.h
│ │ │ ├── STTabBarController.h
│ │ │ ├── STTabBarItem.h
│ │ │ ├── STTableView.h
│ │ │ ├── STTableViewCell.h
│ │ │ ├── STTableViewController.h
│ │ │ ├── STTextView.h
│ │ │ ├── STTheme.h
│ │ │ ├── STThemeManager.h
│ │ │ ├── STTrashManager.h
│ │ │ ├── STURLCache.h
│ │ │ ├── STViewController.h
│ │ │ ├── STWaveAnalysis.h
│ │ │ ├── STWebViewController.h
│ │ │ ├── STZipArchive.h
│ │ │ ├── UIAlertView+STBlock.h
│ │ │ ├── UIImageView+STImageLoader.h
│ │ │ ├── UIKit+STKit.h
│ │ │ ├── UIView+STConstraint.h
│ │ │ └── fft.h
│ │ ├── Info.plist
│ │ └── STKit
│ ├── LaunchScreen.xib
│ ├── Main.storyboard
│ ├── Resources/
│ │ └── licenses.html
│ ├── STDAppDelegate.h
│ ├── STDAppDelegate.m
│ ├── STDemoImages.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Base/
│ │ │ ├── avatar72.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── navigation.imageset/
│ │ │ └── Contents.json
│ │ ├── Chat/
│ │ │ ├── bubble_image_green.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_image_white.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_text_green.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_text_white.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── chat_input_send_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── chat_input_send_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── FeedCell/
│ │ │ ├── feed_cell_background.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── feed_cell_border.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── feed_hot_icon.imageset/
│ │ │ └── Contents.json
│ │ ├── LaunchImage.launchimage/
│ │ │ └── Contents.json
│ │ ├── Navigation/
│ │ │ ├── nav_cancel_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_done_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_menu_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_refresh_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── nav_setting_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── Porn/
│ │ │ ├── article_collect.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── article_collected.imageset/
│ │ │ └── Contents.json
│ │ ├── Publish/
│ │ │ ├── choose_image_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── choose_image_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── hud_done.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── product_default.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── publish_button_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── publish_button_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── publish_tool_bkg.imageset/
│ │ │ └── Contents.json
│ │ ├── SearchBar/
│ │ │ ├── search_cancel_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── search_cancel_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── searchbar_bkg.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── textfield_delete_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── SideBar/
│ │ │ ├── SideBarAvatar_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarAvatar_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarNearby_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarNearby_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarSetting_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarSetting_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarShare_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── SideBarShare_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── TabBar/
│ │ │ ├── tab_bkg.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_message_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_message_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_profile_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_profile_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_receipt_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_receipt_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_service_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── tab_service_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── Test/
│ │ │ ├── button_bkg_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── button_bkg_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── home_search_left_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── home_search_right_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── search_history_edit.imageset/
│ │ │ └── Contents.json
│ │ ├── UIControls/
│ │ │ ├── Menu/
│ │ │ │ ├── wormhole0.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole1.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole2.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole3.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole4.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── wormhole5.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── aero_button.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── viewer_zoom_in.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── viewer_zoom_out.imageset/
│ │ │ └── Contents.json
│ │ ├── ViewController/
│ │ │ ├── left_account_header.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── left_bkg.imageset/
│ │ │ └── Contents.json
│ │ └── terms.imageset/
│ │ └── Contents.json
│ ├── STKitDemo-Info.plist
│ ├── STKitDemo-Prefix.pch
│ ├── STKitDemo.entitlements
│ ├── STKitDemoInHouse-Info.plist
│ ├── Settings.bundle/
│ │ ├── Root.plist
│ │ └── en.lproj/
│ │ └── Root.strings
│ ├── en.lproj/
│ │ └── InfoPlist.strings
│ └── main.m
├── STKitDemo.xcodeproj/
│ └── project.pbxproj
├── STKitDemoTests/
│ ├── DesignPatterns/
│ │ └── Creational/
│ │ ├── STDAbstractFactoryTests.m
│ │ ├── STDFactoryMethodTests.m
│ │ └── STDSingletonTests.m
│ ├── Info.plist
│ └── STKitDemoTests.m
└── STKitWidget/
├── Info.plist
├── MainInterface.storyboard
├── STKitWidgetInHouse-Info.plist
├── TodayViewController.h
└── TodayViewController.m
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.DS_Store
*.swp
*project.xcworkspace
*contents.xcworkspacedata
*.xcuserdata*
*xcuserdata*
.DS_Store
xcuserdata/
xcshareddata/
================================================
FILE: README.md
================================================
A demo of the STKit. Download[STKit](https://github.com/lovesunstar/STKit)
STKit is a collection of useful classes for iOS Developer,it can help you to simplify the approach to develop your iOS applications saving time and more efficiently.
UIKit
```STNavigationController``` (Based on UIViewController)
```STTabBarController``` (Based on UIViewController)
```STSideBarController``` (A container controller)
```STImagePickerController``` (You can select more than one picture)
```STLinkLabel``` (Label contains hyperlink and custom link)
```STImagePresent``` (Preview a list of images with a cool animation)
```UIKit+STKit``` (Some useful categories on uiview)
and so on.
Foundation
```STObject``` (convert JSON->Model)
```STNetwork``` (a network engine based urlconnection and operation queue)
```STImageDownloader``` (Download and cache image)
```STAESCryptor``` (Crypto using AES)
```STRSACryptor``` (Crypto using RSA, including some common way to exact the public key and the private key)
```Foundation+STKit``` (Categories )
and so on
There are many other tools, you can checkout and find them.
I will always update stkit.
Some knowledge can be found in my blogs. [技术哥的博客](http://suenblog.duapp.com)
================================================
FILE: STKitDemo/Classes/3rdLibs/MZCroppableView/MZCroppableView.h
================================================
//
// MZCroppableView.h
// MZCroppableView
//
// Created by macbook on 30/10/2013.
// Copyright (c) 2013 macbook. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MZCroppableView : UIView
{
}
@property(nonatomic, strong) UIBezierPath *croppingPath;
@property(nonatomic, strong) UIColor *lineColor;
@property(nonatomic, assign) float lineWidth;
- (id)initWithImageView:(UIImageView *)imageView;
+ (CGPoint)convertCGPoint:(CGPoint)point1 fromRect1:(CGSize)rect1 toRect2:(CGSize)rect2;
+ (CGPoint)convertPoint:(CGPoint)point1 fromRect1:(CGSize)rect1 toRect2:(CGSize)rect2;
+ (CGRect)scaleRespectAspectFromRect1:(CGRect)rect1 toRect2:(CGRect)rect2;
- (UIImage *)deleteBackgroundOfImage:(UIImageView *)image;
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/MZCroppableView/MZCroppableView.m
================================================
//
// MZCroppableView.m
// MZCroppableView
//
// Created by macbook on 30/10/2013.
// Copyright (c) 2013 macbook. All rights reserved.
//
#import "MZCroppableView.h"
#import "UIBezierPath-Points.h"
@implementation MZCroppableView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
- (id)initWithImageView:(UIImageView *)imageView
{
self = [super initWithFrame:imageView.frame];
if (self) {
self.lineWidth = 2.0f;
[self setBackgroundColor:[UIColor clearColor]];
[self setClipsToBounds:YES];
[self setUserInteractionEnabled:YES];
self.croppingPath = [[UIBezierPath alloc] init];
[self.croppingPath setLineWidth:self.lineWidth];
self.lineColor = [UIColor colorWithRed:0xFF/255. green:0x73/255. blue:0 alpha:1.];
}
return self;
}
#pragma mark - My Methods -
+ (CGRect)scaleRespectAspectFromRect1:(CGRect)rect1 toRect2:(CGRect)rect2
{
CGSize scaledSize = rect2.size;
float scaleFactor = 1.0;
CGFloat widthFactor = rect2.size.width / rect1.size.width;
CGFloat heightFactor = rect2.size.height / rect1.size.width;
if (widthFactor < heightFactor)
scaleFactor = widthFactor;
else
scaleFactor = heightFactor;
scaledSize.height = rect1.size.height *scaleFactor;
scaledSize.width = rect1.size.width *scaleFactor;
float y = (rect2.size.height - scaledSize.height)/2;
return CGRectMake(0, y, scaledSize.width, scaledSize.height);
}
+ (CGPoint)convertCGPoint:(CGPoint)point1 fromRect1:(CGSize)rect1 toRect2:(CGSize)rect2
{
point1.y = rect1.height - point1.y;
CGPoint result = CGPointMake((point1.x*rect2.width)/rect1.width, (point1.y*rect2.height)/rect1.height);
return result;
}
+ (CGPoint)convertPoint:(CGPoint)point1 fromRect1:(CGSize)rect1 toRect2:(CGSize)rect2
{
CGPoint result = CGPointMake((point1.x*rect2.width)/rect1.width, (point1.y*rect2.height)/rect1.height);
return result;
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
[self.lineColor setStroke];
[self.croppingPath strokeWithBlendMode:kCGBlendModeNormal alpha:1.0f];
}
- (UIImage *)deleteBackgroundOfImage:(UIImageView *)image
{
NSArray *points = [self.croppingPath points];
CGRect rect = CGRectZero;
rect.size = image.image.size;
UIBezierPath *aPath;
UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0);
{
[[UIColor blackColor] setFill];
UIRectFill(rect);
[[UIColor whiteColor] setFill];
aPath = [UIBezierPath bezierPath];
// Set the starting point of the shape.
CGPoint point = ([points[0] isKindOfClass:[NSString class]]) ? CGPointFromString(points[0]) : [points[0] CGPointValue];
CGPoint p1 = [MZCroppableView convertCGPoint:point fromRect1:image.frame.size toRect2:image.image.size];
[aPath moveToPoint:CGPointMake(p1.x, p1.y)];
for (uint i=1; i<points.count; i++)
{
id pvalue = points[i];
CGPoint p = CGPointZero;
if ([pvalue isKindOfClass:[NSString class]]) {
p = CGPointFromString(pvalue);
} else {
p = [pvalue CGPointValue];
}
p = [MZCroppableView convertCGPoint:p fromRect1:image.frame.size toRect2:image.image.size];
[aPath addLineToPoint:CGPointMake(p.x, p.y)];
}
[aPath closePath];
[aPath fill];
}
UIImage *mask = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0.0);
{
CGContextClipToMask(UIGraphicsGetCurrentContext(), rect, mask.CGImage);
[image.image drawAtPoint:CGPointZero];
}
UIImage *maskedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGRect croppedRect = aPath.bounds;
croppedRect.origin.y = rect.size.height - CGRectGetMaxY(aPath.bounds);//This because mask become inverse of the actual image;
croppedRect.origin.x = croppedRect.origin.x*2;
croppedRect.origin.y = croppedRect.origin.y*2;
croppedRect.size.width = croppedRect.size.width*2;
croppedRect.size.height = croppedRect.size.height*2;
CGImageRef imageRef = CGImageCreateWithImageInRect(maskedImage.CGImage, croppedRect);
maskedImage = [UIImage imageWithCGImage:imageRef];
CFRelease(imageRef);
return maskedImage;
}
#pragma mark - Touch Methods -
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[self.croppingPath moveToPoint:[mytouch locationInView:self]];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *mytouch=[[touches allObjects] objectAtIndex:0];
[self.croppingPath addLineToPoint:[mytouch locationInView:self]];
[self setNeedsDisplay];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
}
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/MZCroppableView/UIBezierPath-Points.h
================================================
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import <Foundation/Foundation.h>
@interface UIBezierPath (Points)
@property (nonatomic, readonly) NSArray *points;
@property (nonatomic, readonly) NSArray *bezierElements;
@property (nonatomic, readonly) CGFloat length;
- (NSArray *) pointPercentArray;
- (CGPoint) pointAtPercent: (CGFloat) percent withSlope: (CGPoint *) slope;
+ (UIBezierPath *) pathWithPoints: (NSArray *) points;
+ (UIBezierPath *) pathWithElements: (NSArray *) elements;
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/MZCroppableView/UIBezierPath-Points.m
================================================
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import "UIBezierPath-Points.h"
#define POINTSTRING(_CGPOINT_) (NSStringFromCGPoint(_CGPOINT_))
#define VALUE(_INDEX_) NSStringFromCGPoint(points[_INDEX_])
#define POINT(_INDEX_) CGPointFromString(points[_INDEX_])
// Return distance between two points
static CGFloat distance (CGPoint p1, CGPoint p2)
{
CGFloat dx = p2.x - p1.x;
CGFloat dy = p2.y - p1.y;
return sqrt(dx*dx + dy*dy);
}
@implementation UIBezierPath (Points)
void getPointsFromBezier(void *info, const CGPathElement *element)
{
NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info;
CGPathElementType type = element->type;
CGPoint *points = element->points;
if (type != kCGPathElementCloseSubpath)
{
if ((type == kCGPathElementAddLineToPoint) ||
(type == kCGPathElementMoveToPoint))
[bezierPoints addObject:VALUE(0)];
else if (type == kCGPathElementAddQuadCurveToPoint)
[bezierPoints addObject:VALUE(1)];
else if (type == kCGPathElementAddCurveToPoint)
[bezierPoints addObject:VALUE(2)];
}
}
- (NSArray *)points
{
NSMutableArray *points = [NSMutableArray array];
CGPathApply(self.CGPath, (__bridge void *)points, getPointsFromBezier);
return points;
}
// Return a Bezier path buit with the supplied points
+ (UIBezierPath *) pathWithPoints: (NSArray *) points
{
UIBezierPath *path = [UIBezierPath bezierPath];
if (points.count == 0) return path;
[path moveToPoint:POINT(0)];
for (int i = 1; i < points.count; i++)
[path addLineToPoint:POINT(i)];
return path;
}
- (CGFloat) length
{
NSArray *points = self.points;
float totalPointLength = 0.0f;
for (int i = 1; i < points.count; i++)
totalPointLength += distance(POINT(i), POINT(i-1));
return totalPointLength;
}
- (NSArray *) pointPercentArray
{
// Use total length to calculate the percent of path consumed at each control point
NSArray *points = self.points;
NSInteger pointCount = points.count;
CGFloat totalPointLength = self.length;
CGFloat distanceTravelled = 0.0f;
NSMutableArray *pointPercentArray = [NSMutableArray array];
[pointPercentArray addObject:@(0.0f)];
for (int i = 1; i < pointCount; i++)
{
distanceTravelled += distance(POINT(i), POINT(i-1));
[pointPercentArray addObject:@(distanceTravelled / totalPointLength)];
}
// Add a final item just to stop with. Probably not needed.
[pointPercentArray addObject:@1.1f]; // 110%
return pointPercentArray;
}
- (CGPoint) pointAtPercent: (CGFloat) percent withSlope: (CGPoint *) slope
{
NSArray *points = self.points;
NSArray *percentArray = self.pointPercentArray;
CFIndex lastPointIndex = points.count - 1;
if (!points.count)
return CGPointZero;
// Check for 0% and 100%
if (percent <= 0.0f) return POINT(0);
if (percent >= 1.0f) return POINT(lastPointIndex);
// Find a corresponding pair of points in the path
CFIndex index = 1;
while ((index < percentArray.count) &&
(percent > ((NSNumber *)percentArray[index]).floatValue))
index++;
// This should not happen.
if (index > lastPointIndex) return POINT(lastPointIndex);
// Calculate the intermediate distance between the two points
CGPoint point1 = POINT(index -1);
CGPoint point2 = POINT(index);
CGFloat percent1 = [[percentArray objectAtIndex:index - 1] floatValue];
CGFloat percent2 = [[percentArray objectAtIndex:index] floatValue];
CGFloat percentOffset = (percent - percent1) / (percent2 - percent1);
CGFloat dx = point2.x - point1.x;
CGFloat dy = point2.y - point1.y;
// Store dy, dx for retrieving arctan
if (slope) *slope = CGPointMake(dx, dy);
// Calculate new point
CGFloat newX = point1.x + (percentOffset * dx);
CGFloat newY = point1.y + (percentOffset * dy);
CGPoint targetPoint = CGPointMake(newX, newY);
return targetPoint;
}
void getBezierElements(void *info, const CGPathElement *element)
{
NSMutableArray *bezierElements = (__bridge NSMutableArray *)info;
CGPathElementType type = element->type;
CGPoint *points = element->points;
switch (type)
{
case kCGPathElementCloseSubpath:
[bezierElements addObject:@[@(type)]];
break;
case kCGPathElementMoveToPoint:
case kCGPathElementAddLineToPoint:
[bezierElements addObject:@[@(type), VALUE(0)]];
break;
case kCGPathElementAddQuadCurveToPoint:
[bezierElements addObject:@[@(type), VALUE(0), VALUE(1)]];
break;
case kCGPathElementAddCurveToPoint:
[bezierElements addObject:@[@(type), VALUE(0), VALUE(1), VALUE(2)]];
break;
}
}
- (NSArray *) bezierElements
{
NSMutableArray *elements = [NSMutableArray array];
CGPathApply(self.CGPath, (__bridge void *)elements, getBezierElements);
return elements;
}
+ (UIBezierPath *) pathWithElements: (NSArray *) elements
{
UIBezierPath *path = [UIBezierPath bezierPath];
if (elements.count == 0) return path;
for (NSArray *points in elements)
{
if (!points.count) continue;
CGPathElementType elementType = (CGPathElementType)[points[0] integerValue];
switch (elementType)
{
case kCGPathElementCloseSubpath:
[path closePath];
break;
case kCGPathElementMoveToPoint:
if (points.count == 2)
[path moveToPoint:POINT(1)];
break;
case kCGPathElementAddLineToPoint:
if (points.count == 2)
[path addLineToPoint:POINT(1)];
break;
case kCGPathElementAddQuadCurveToPoint:
if (points.count == 3)
[path addQuadCurveToPoint:POINT(2) controlPoint:POINT(1)];
break;
case kCGPathElementAddCurveToPoint:
if (points.count == 4)
[path addCurveToPoint:POINT(3) controlPoint1:POINT(1) controlPoint2:POINT(2)];
break;
}
}
return path;
}
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/PingTester/SimplePing.h
================================================
/*
File: SimplePing.h
Contains: Implements ping.
Written by: DTS
Copyright: Copyright (c) 2010 Apple Inc. All Rights Reserved.
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or
redistribution of this Apple software constitutes acceptance of
these terms. If you do not agree with these terms, please do
not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following
terms, and subject to these terms, Apple grants you a personal,
non-exclusive license, under Apple's copyrights in this
original Apple software (the "Apple Software"), to use,
reproduce, modify and redistribute the Apple Software, with or
without modifications, in source and/or binary forms; provided
that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the
following text and disclaimers in all such redistributions of
the Apple Software. Neither the name, trademarks, service marks
or logos of Apple Inc. may be used to endorse or promote
products derived from the Apple Software without specific prior
written permission from Apple. Except as expressly stated in
this notice, no other rights or licenses, express or implied,
are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or
by other works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis.
APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY
OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#import <Foundation/Foundation.h>
#if TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR
#import <CFNetwork/CFNetwork.h>
#else
#import <CoreServices/CoreServices.h>
#endif
#include <AssertMacros.h>
#pragma mark * SimplePing
// The SimplePing class is a very simple class that lets you send and receive pings.
#pragma mark * IP and ICMP On-The-Wire Format
// The following declarations specify the structure of ping packets on the wire.
// IP header structure:
struct IPHeader {
uint8_t versionAndHeaderLength;
uint8_t differentiatedServices;
uint16_t totalLength;
uint16_t identification;
uint16_t flagsAndFragmentOffset;
uint8_t timeToLive;
uint8_t protocol;
uint16_t headerChecksum;
uint8_t sourceAddress[4];
uint8_t destinationAddress[4];
// options...
// data...
};
typedef struct IPHeader IPHeader;
// ICMP type and code combinations:
enum {
kICMPTypeEchoReply = 0, // code is always 0
kICMPTypeEchoRequest = 8 // code is always 0
};
// ICMP header structure:
struct ICMPHeader {
uint8_t type;
uint8_t code;
uint16_t checksum;
uint16_t identifier;
uint16_t sequenceNumber;
// data...
};
typedef struct ICMPHeader ICMPHeader;
@protocol SimplePingDelegate;
@interface SimplePing : NSObject
{
NSString * _hostName;
NSData * _hostAddress;
CFHostRef _host;
CFSocketRef _socket;
id<SimplePingDelegate> _delegate;
uint16_t _identifier; // host byte order
uint16_t _nextSequenceNumber; // host byte order
}
+ (SimplePing *)simplePingWithHostName:(NSString *)hostName; // chooses first IPv4 address
+ (SimplePing *)simplePingWithHostAddress:(NSData *)hostAddress; // contains (struct sockaddr)
@property (nonatomic, assign, readwrite) id<SimplePingDelegate> delegate;
@property (nonatomic, copy, readonly) NSString * hostName;
@property (nonatomic, copy, readonly) NSData * hostAddress;
@property (nonatomic, assign, readonly) uint16_t identifier;
@property (nonatomic, assign, readonly) uint16_t nextSequenceNumber;
@property (nonatomic, copy) NSString *IPAddress;
- (void)start;
// Starts the pinger object pinging. You should call this after
// you've setup the delegate and any ping parameters.
- (void)sendPingWithData:(NSData *)data;
// Sends an actual ping. Pass nil for data to use a standard 56 byte payload (resulting in a
// standard 64 byte ping). Otherwise pass a non-nil value and it will be appended to the
// ICMP header.
//
// Do not try to send a ping before you receive the -simplePing:didStartWithAddress: delegate
// callback.
- (void)stop;
// Stops the pinger object. You should call this when you're done
// pinging.
+ (const struct ICMPHeader *)icmpInPacket:(NSData *)packet;
// Given a valid IP packet contains an ICMP , returns the address of the ICMP header that
// follows the IP header. This doesn't do any significant validation of the packet.
@end
@protocol SimplePingDelegate <NSObject>
@optional
- (void)simplePing:(SimplePing *)pinger didStartWithAddress:(NSData *)address;
// Called after the SimplePing has successfully started up. After this callback, you
// can start sending pings via -sendPingWithData:
- (void)simplePing:(SimplePing *)pinger didFailWithError:(NSError *)error;
// If this is called, the SimplePing object has failed. By the time this callback is
// called, the object has stopped (that is, you don't need to call -stop yourself).
// IMPORTANT: On the send side the packet does not include an IP header.
// On the receive side, it does. In that case, use +[SimplePing icmpInPacket:]
// to find the ICMP header within the packet.
- (void)simplePing:(SimplePing *)pinger didSendPacket:(NSData *)packet ICMPHeader:(ICMPHeader *)ICMPHeader;
// Called whenever the SimplePing object has successfully sent a ping packet.
- (void)simplePing:(SimplePing *)pinger didFailToSendPacket:(NSData *)packet error:(NSError *)error;
// Called whenever the SimplePing object tries and fails to send a ping packet.
- (void)simplePing:(SimplePing *)pinger didReceivePingResponsePacket:(NSData *)packet timeElasped:(NSTimeInterval)timeElasped;
// Called whenever the SimplePing object receives an ICMP packet that looks like
// a response to one of our pings (that is, has a valid ICMP checksum, has
// an identifier that matches our identifier, and has a sequence number in
// the range of sequence numbers that we've sent out).
- (void)simplePing:(SimplePing *)pinger didReceiveUnexpectedPacket:(NSData *)packet;
// Called whenever the SimplePing object receives an ICMP packet that does not
// look like a response to one of our pings.
@end
check_compile_time(sizeof(IPHeader) == 20);
check_compile_time(offsetof(IPHeader, versionAndHeaderLength) == 0);
check_compile_time(offsetof(IPHeader, differentiatedServices) == 1);
check_compile_time(offsetof(IPHeader, totalLength) == 2);
check_compile_time(offsetof(IPHeader, identification) == 4);
check_compile_time(offsetof(IPHeader, flagsAndFragmentOffset) == 6);
check_compile_time(offsetof(IPHeader, timeToLive) == 8);
check_compile_time(offsetof(IPHeader, protocol) == 9);
check_compile_time(offsetof(IPHeader, headerChecksum) == 10);
check_compile_time(offsetof(IPHeader, sourceAddress) == 12);
check_compile_time(offsetof(IPHeader, destinationAddress) == 16);
check_compile_time(sizeof(ICMPHeader) == 8);
check_compile_time(offsetof(ICMPHeader, type) == 0);
check_compile_time(offsetof(ICMPHeader, code) == 1);
check_compile_time(offsetof(ICMPHeader, checksum) == 2);
check_compile_time(offsetof(ICMPHeader, identifier) == 4);
check_compile_time(offsetof(ICMPHeader, sequenceNumber) == 6);
================================================
FILE: STKitDemo/Classes/3rdLibs/PingTester/SimplePing.m
================================================
/*
File: SimplePing.m
Contains: Implements ping.
Written by: DTS
Copyright: Copyright (c) 2010 Apple Inc. All Rights Reserved.
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or
redistribution of this Apple software constitutes acceptance of
these terms. If you do not agree with these terms, please do
not use, install, modify or redistribute this Apple software.
In consideration of your agreement to abide by the following
terms, and subject to these terms, Apple grants you a personal,
non-exclusive license, under Apple's copyrights in this
original Apple software (the "Apple Software"), to use,
reproduce, modify and redistribute the Apple Software, with or
without modifications, in source and/or binary forms; provided
that if you redistribute the Apple Software in its entirety and
without modifications, you must retain this notice and the
following text and disclaimers in all such redistributions of
the Apple Software. Neither the name, trademarks, service marks
or logos of Apple Inc. may be used to endorse or promote
products derived from the Apple Software without specific prior
written permission from Apple. Except as expressly stated in
this notice, no other rights or licenses, express or implied,
are granted by Apple herein, including but not limited to any
patent rights that may be infringed by your derivative works or
by other works in which the Apple Software may be incorporated.
The Apple Software is provided by Apple on an "AS IS" basis.
APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING
THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
COMBINATION WITH YOUR PRODUCTS.
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY
OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
#import "SimplePing.h"
#include <sys/socket.h>
#include <netinet/in.h>
#import <netdb.h>
#pragma mark * ICMP On-The-Wire Format
static uint16_t in_cksum(const void *buffer, size_t bufferLen)
// This is the standard BSD checksum code, modified to use modern types.
{
size_t bytesLeft;
int32_t sum;
const uint16_t * cursor;
union {
uint16_t us;
uint8_t uc[2];
} last;
uint16_t answer;
bytesLeft = bufferLen;
sum = 0;
cursor = buffer;
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
while (bytesLeft > 1) {
sum += *cursor;
cursor += 1;
bytesLeft -= 2;
}
/* mop up an odd byte, if necessary */
if (bytesLeft == 1) {
last.uc[0] = * (const uint8_t *) cursor;
last.uc[1] = 0;
sum += last.us;
}
/* add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return answer;
}
#pragma mark * SimplePing
@interface SimplePing ()
@property (nonatomic, copy, readwrite) NSData * hostAddress;
@property (nonatomic, assign, readwrite) uint16_t nextSequenceNumber;
@property (nonatomic, retain) NSDate *pingStartDate;
- (void)_stopHostResolution;
- (void)_stopDataTransfer;
@end
@implementation SimplePing
- (id)initWithHostName:(NSString *)hostName address:(NSData *)hostAddress
// The initialiser common to both of our construction class methods.
{
assert( (hostName != nil) == (hostAddress == nil) );
self = [super init];
if (self != nil) {
self->_hostName = [hostName copy];
self->_hostAddress = [hostAddress copy];
self->_identifier = (uint16_t) arc4random();
}
return self;
}
- (void)dealloc {
// -stop takes care of _host and _socket.
[self stop];
assert(self->_host == NULL);
assert(self->_socket == NULL);
[self->_hostName release];
[self->_hostAddress release];
self.IPAddress = nil;
[super dealloc];
}
+ (SimplePing *)simplePingWithHostName:(NSString *)hostName
// See comment in header.
{
return [[[SimplePing alloc] initWithHostName:hostName address:nil] autorelease];
}
+ (SimplePing *)simplePingWithHostAddress:(NSData *)hostAddress
// See comment in header.
{
return [[[SimplePing alloc] initWithHostName:NULL address:hostAddress] autorelease];
}
@synthesize hostName = _hostName;
@synthesize hostAddress = _hostAddress;
@synthesize delegate = _delegate;
@synthesize identifier = _identifier;
@synthesize nextSequenceNumber = _nextSequenceNumber;
- (void)_didFailWithError:(NSError *)error
// Shut down the pinger object and tell the delegate about the error.
{
assert(error != nil);
// We retain ourselves temporarily because it's common for the delegate method
// to release its last reference to use, which causes -dealloc to be called here.
// If we then reference self on the return path, things go badly. I don't think
// that happens currently, but I've got into the habit of doing this as a
// defensive measure.
[[self retain] autorelease];
[self stop];
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didFailWithError:)] ) {
[self.delegate simplePing:self didFailWithError:error];
}
}
- (void)_didFailWithHostStreamError:(CFStreamError)streamError
// Convert the CFStreamError to an NSError and then call through to
// -_didFailWithError: to shut down the pinger object and tell the
// delegate about the error.
{
NSDictionary * userInfo;
NSError * error;
if (streamError.domain == kCFStreamErrorDomainNetDB) {
userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:streamError.error], kCFGetAddrInfoFailureKey,
nil
];
} else {
userInfo = nil;
}
error = [NSError errorWithDomain:(NSString *)kCFErrorDomainCFNetwork code:kCFHostErrorUnknown userInfo:userInfo];
assert(error != nil);
[self _didFailWithError:error];
}
- (void)sendPingWithData:(NSData *)data
// See comment in header.
{
int err;
NSData * payload;
NSMutableData * packet;
ICMPHeader * icmpPtr;
ssize_t bytesSent;
// Construct the ping packet.
payload = data;
if (payload == nil) {
payload = [[NSString stringWithFormat:@"%28zd bottles of beer on the wall", (ssize_t) 99 - (size_t) (self.nextSequenceNumber % 100) ] dataUsingEncoding:NSASCIIStringEncoding];
assert(payload != nil);
assert([payload length] == 56);
}
packet = [NSMutableData dataWithLength:sizeof(*icmpPtr) + [payload length]];
assert(packet != nil);
icmpPtr = [packet mutableBytes];
icmpPtr->type = kICMPTypeEchoRequest;
icmpPtr->code = 0;
icmpPtr->checksum = 0;
icmpPtr->identifier = OSSwapHostToBigInt16(self.identifier);
icmpPtr->sequenceNumber = OSSwapHostToBigInt16(self.nextSequenceNumber);
memcpy(&icmpPtr[1], [payload bytes], [payload length]);
// The IP checksum returns a 16-bit number that's already in correct byte order
// (due to wacky 1's complement maths), so we just put it into the packet as a
// 16-bit unit.
icmpPtr->checksum = in_cksum([packet bytes], [packet length]);
// Send the packet.
if (self->_socket == NULL) {
bytesSent = -1;
err = EBADF;
} else {
bytesSent = sendto(
CFSocketGetNative(self->_socket),
[packet bytes],
[packet length],
0,
(struct sockaddr *) [self.hostAddress bytes],
(socklen_t) [self.hostAddress length]
);
err = 0;
if (bytesSent < 0) {
err = errno;
}
}
// Handle the results of the send.
self.pingStartDate = nil;
if ( (bytesSent > 0) && (((NSUInteger) bytesSent) == [packet length]) ) {
self.pingStartDate = [NSDate date];
// Complete success. Tell the client.
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didSendPacket:ICMPHeader:)] ) {
[self.delegate simplePing:self didSendPacket:packet ICMPHeader:icmpPtr];
}
} else {
NSError * error;
// Some sort of failure. Tell the client.
if (err == 0) {
err = ENOBUFS; // This is not a hugely descriptor error, alas.
}
error = [NSError errorWithDomain:NSPOSIXErrorDomain code:err userInfo:nil];
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didFailToSendPacket:error:)] ) {
[self.delegate simplePing:self didFailToSendPacket:packet error:error];
}
}
self.nextSequenceNumber += 1;
}
+ (NSUInteger)_icmpHeaderOffsetInPacket:(NSData *)packet
// Returns the offset of the ICMPHeader within an IP packet.
{
NSUInteger result;
const struct IPHeader * ipPtr;
size_t ipHeaderLength;
result = NSNotFound;
if ([packet length] >= (sizeof(IPHeader) + sizeof(ICMPHeader))) {
ipPtr = (const IPHeader *) [packet bytes];
assert((ipPtr->versionAndHeaderLength & 0xF0) == 0x40); // IPv4
assert(ipPtr->protocol == 1); // ICMP
ipHeaderLength = (ipPtr->versionAndHeaderLength & 0x0F) * sizeof(uint32_t);
if ([packet length] >= (ipHeaderLength + sizeof(ICMPHeader))) {
result = ipHeaderLength;
}
}
return result;
}
+ (const struct ICMPHeader *)icmpInPacket:(NSData *)packet
// See comment in header.
{
const struct ICMPHeader * result;
NSUInteger icmpHeaderOffset;
result = nil;
icmpHeaderOffset = [self _icmpHeaderOffsetInPacket:packet];
if (icmpHeaderOffset != NSNotFound) {
result = (const struct ICMPHeader *) (((const uint8_t *)[packet bytes]) + icmpHeaderOffset);
}
return result;
}
- (BOOL)_isValidPingResponsePacket:(NSMutableData *)packet
// Returns true if the packet looks like a valid ping response packet destined
// for us.
{
BOOL result;
NSUInteger icmpHeaderOffset;
ICMPHeader * icmpPtr;
uint16_t receivedChecksum;
uint16_t calculatedChecksum;
result = NO;
icmpHeaderOffset = [[self class] _icmpHeaderOffsetInPacket:packet];
if (icmpHeaderOffset != NSNotFound) {
icmpPtr = (struct ICMPHeader *) (((uint8_t *)[packet mutableBytes]) + icmpHeaderOffset);
receivedChecksum = icmpPtr->checksum;
icmpPtr->checksum = 0;
calculatedChecksum = in_cksum(icmpPtr, [packet length] - icmpHeaderOffset);
icmpPtr->checksum = receivedChecksum;
if (receivedChecksum == calculatedChecksum) {
if ( (icmpPtr->type == kICMPTypeEchoReply) && (icmpPtr->code == 0) ) {
if ( OSSwapBigToHostInt16(icmpPtr->identifier) == self.identifier ) {
if ( OSSwapBigToHostInt16(icmpPtr->sequenceNumber) < self.nextSequenceNumber ) {
result = YES;
}
}
}
}
}
return result;
}
- (void)_readData
// Called by the socket handling code (SocketReadCallback) to process an ICMP
// messages waiting on the socket.
{
int err;
struct sockaddr_storage addr;
socklen_t addrLen;
ssize_t bytesRead;
void * buffer;
enum { kBufferSize = 65535 };
// 65535 is the maximum IP packet size, which seems like a reasonable bound
// here (plus it's what <x-man-page://8/ping> uses).
buffer = malloc(kBufferSize);
assert(buffer != NULL);
// Actually read the data.
addrLen = sizeof(addr);
bytesRead = recvfrom(CFSocketGetNative(self->_socket), buffer, kBufferSize, 0, (struct sockaddr *) &addr, &addrLen);
err = 0;
if (bytesRead < 0) {
err = errno;
}
// Process the data we read.
if (bytesRead > 0) {
NSMutableData * packet;
packet = [NSMutableData dataWithBytes:buffer length:bytesRead];
assert(packet != nil);
// We got some data, pass it up to our client.
NSTimeInterval timeInterval = 0.0f;
if (self.pingStartDate) {
timeInterval = [[NSDate date] timeIntervalSinceDate:self.pingStartDate];
}
if ( [self _isValidPingResponsePacket:packet] ) {
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didReceivePingResponsePacket:timeElasped:)] ) {
[self.delegate simplePing:self didReceivePingResponsePacket:packet timeElasped:timeInterval];
}
} else {
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didReceiveUnexpectedPacket:)] ) {
[self.delegate simplePing:self didReceiveUnexpectedPacket:packet];
}
}
} else {
// We failed to read the data, so shut everything down.
if (err == 0) {
err = EPIPE;
}
[self _didFailWithError:[NSError errorWithDomain:NSPOSIXErrorDomain code:err userInfo:nil]];
}
self.pingStartDate = nil;
free(buffer);
// Note that we don't loop back trying to read more data. Rather, we just
// let CFSocket call us again.
}
static void SocketReadCallback(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
// This C routine is called by CFSocket when there's data waiting on our
// ICMP socket. It just redirects the call to Objective-C code.
{
SimplePing * obj;
obj = (SimplePing *) info;
assert([obj isKindOfClass:[SimplePing class]]);
#pragma unused(s)
assert(s == obj->_socket);
#pragma unused(type)
assert(type == kCFSocketReadCallBack);
#pragma unused(address)
assert(address == nil);
#pragma unused(data)
assert(data == nil);
[obj _readData];
}
- (void)_startWithHostAddress
// We have a host address, so let's actually start pinging it.
{
int err;
int fd;
const struct sockaddr * addrPtr;
char ipAddress[INET6_ADDRSTRLEN];
assert(self.hostAddress != nil);
// Open the socket.
addrPtr = (const struct sockaddr *) [self.hostAddress bytes];
/* getnameinfo coverts an IPv4 or IPv6 address into a text string. */
int eno = getnameinfo(addrPtr, addrPtr->sa_len, ipAddress, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
if (eno == 0) {
NSString *IPAddress = [[[NSString alloc] initWithFormat:@"%s",ipAddress] autorelease];
// NSLog(@"%@", IPAddress);
self.IPAddress = IPAddress;
}
fd = -1;
err = 0;
switch (addrPtr->sa_family) {
case AF_INET: {
fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
if (fd < 0) {
err = errno;
}
} break;
case AF_INET6:
assert(NO);
// fall through
default: {
err = EPROTONOSUPPORT;
} break;
}
if (err != 0) {
[self _didFailWithError:[NSError errorWithDomain:NSPOSIXErrorDomain code:err userInfo:nil]];
} else {
CFSocketContext context = {0, self, NULL, NULL, NULL};
CFRunLoopSourceRef rls;
// Wrap it in a CFSocket and schedule it on the runloop.
self->_socket = CFSocketCreateWithNative(NULL, fd, kCFSocketReadCallBack, SocketReadCallback, &context);
assert(self->_socket != NULL);
// The socket will now take care of clean up our file descriptor.
assert( CFSocketGetSocketFlags(self->_socket) & kCFSocketCloseOnInvalidate );
fd = -1;
rls = CFSocketCreateRunLoopSource(NULL, self->_socket, 0);
assert(rls != NULL);
CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
CFRelease(rls);
if ( (self.delegate != nil) && [self.delegate respondsToSelector:@selector(simplePing:didStartWithAddress:)] ) {
[self.delegate simplePing:self didStartWithAddress:self.hostAddress];
}
}
assert(fd == -1);
}
- (void)_hostResolutionDone
// Called by our CFHost resolution callback (HostResolveCallback) when host
// resolution is complete. We just latch the first IPv4 address and kick
// off the pinging process.
{
Boolean resolved;
NSArray * addresses;
char ipAddress[INET6_ADDRSTRLEN];
// Find the first IPv4 address.
addresses = (NSArray *)CFHostGetAddressing(self->_host, &resolved);
if ( resolved && (addresses != nil) ) {
resolved = false;
for (NSData * address in addresses) {
const struct sockaddr * addrPtr;
addrPtr = (const struct sockaddr *) [address bytes];
if ([address length] >= sizeof(struct sockaddr) && addrPtr->sa_family == AF_INET) {
self.hostAddress = address;
resolved = true;
/* getnameinfo coverts an IPv4 or IPv6 address into a text string. */
int err = getnameinfo(addrPtr, addrPtr->sa_len, ipAddress, INET6_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST);
if (err == 0) {
NSString *IPAddress = [[[NSString alloc] initWithFormat:@"%s",ipAddress] autorelease];
self.IPAddress = IPAddress;
}
break;
}
}
}
// We're done resolving, so shut that down.
[self _stopHostResolution];
// If all is OK, start pinging, otherwise shut down the pinger completely.
if (resolved) {
[self _startWithHostAddress];
} else {
[self _didFailWithError:[NSError errorWithDomain:(NSString *)kCFErrorDomainCFNetwork code:kCFHostErrorHostNotFound userInfo:nil]];
}
}
static void HostResolveCallback(CFHostRef theHost, CFHostInfoType typeInfo, const CFStreamError *error, void *info)
// This C routine is called by CFHost when the host resolution is complete.
// It just redirects the call to the appropriate Objective-C method.
{
SimplePing * obj;
obj = (SimplePing *) info;
assert([obj isKindOfClass:[SimplePing class]]);
#pragma unused(theHost)
assert(theHost == obj->_host);
#pragma unused(typeInfo)
assert(typeInfo == kCFHostAddresses);
if ( (error != NULL) && (error->domain != 0) ) {
[obj _didFailWithHostStreamError:*error];
} else {
[obj _hostResolutionDone];
}
}
- (void)start
// See comment in header.
{
// If the user supplied us with an address, just start pinging that. Otherwise
// start a host resolution.
if (self->_hostAddress != nil) {
[self _startWithHostAddress];
} else {
Boolean success;
CFHostClientContext context = {0, self, NULL, NULL, NULL};
CFStreamError streamError;
assert(self->_host == NULL);
self->_host = CFHostCreateWithName(NULL, (CFStringRef) self.hostName);
assert(self->_host != NULL);
CFHostSetClient(self->_host, HostResolveCallback, &context);
CFHostScheduleWithRunLoop(self->_host, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
success = CFHostStartInfoResolution(self->_host, kCFHostAddresses, &streamError);
if ( ! success ) {
[self _didFailWithHostStreamError:streamError];
}
}
}
- (void)_stopHostResolution
// Shut down the CFHost.
{
if (self->_host != NULL) {
CFHostSetClient(self->_host, NULL, NULL);
CFHostUnscheduleFromRunLoop(self->_host, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
CFRelease(self->_host);
self->_host = NULL;
}
}
- (void)_stopDataTransfer
// Shut down anything to do with sending and receiving pings.
{
if (self->_socket != NULL) {
CFSocketInvalidate(self->_socket);
CFRelease(self->_socket);
self->_socket = NULL;
}
}
- (void)stop
// See comment in header.
{
[self _stopHostResolution];
[self _stopDataTransfer];
// If we were started with a host name, junk the host address on stop. If the
// client calls -start again, we'll re-resolve the host name.
if (self.hostName != nil) {
self.hostAddress = NULL;
}
}
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/SphereView/PFGoldenSectionSpiral.h
================================================
//This file is part of SphereView.
//
//SphereView is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//SphereView is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with SphereView. If not, see <http://www.gnu.org/licenses/>.
#import <math.h>
#define PFMatrixMaxSize 4
typedef Float32 STFloat32;
struct PFMatrix {
NSInteger m;
NSInteger n;
STFloat32 data[PFMatrixMaxSize][PFMatrixMaxSize];
};
typedef struct PFMatrix PFMatrix;
typedef enum {
PFAxisDirectionNone,
PFAxisDirectionPositive = 1,
PFAxisDirectionNegative = -1
} PFAxisDirection;
static STFloat32 PFAxisDirectionMinimumDistance = 0.033f;
struct PFPoint {
STFloat32 x;
STFloat32 y;
STFloat32 z;
};
typedef struct PFPoint PFPoint;
@interface PFGoldenSectionSpiral : NSObject {
}
+ (NSArray *)sphere:(NSInteger)n;
@end
typedef STFloat32 PFRadian;
extern PFRadian PFRadianMake(STFloat32 grades);
extern PFMatrix PFMatrixTransform3DMakeFromPFPoint(PFPoint point);
extern PFMatrix PFMatrixTransform3DMakeTranslation(PFPoint point);
extern PFMatrix PFMatrixTransform3DMakeXRotation(PFRadian angle);
extern PFMatrix PFMatrixTransform3DMakeXRotationOnPoint(PFPoint point, PFRadian angle);
extern PFMatrix PFMatrixTransform3DMakeYRotation(PFRadian angle);
extern PFMatrix PFMatrixTransform3DMakeYRotationOnPoint(PFPoint point, PFRadian angle);
extern PFMatrix PFMatrixTransform3DMakeZRotation(PFRadian angle);
extern PFMatrix PFMatrixTransform3DMakeZRotationOnPoint(PFPoint point, PFRadian angle);
extern PFMatrix PFMatrixMake(NSInteger m, NSInteger n);
extern PFMatrix PFMatrixMakeFromArray(NSInteger m, NSInteger n, STFloat32 *data);
extern PFMatrix PFMatrixMakeIdentity(NSInteger m, NSInteger n);
extern PFMatrix PFMatrixMultiply(PFMatrix A, PFMatrix B);
extern NSString *NSStringFromPFMatrix(PFMatrix matrix);
extern PFPoint PFPointMake(STFloat32 x, STFloat32 y, STFloat32 z);
extern PFPoint PFPointMakeFromMatrix(PFMatrix matrix);
extern PFPoint PFPointFromString(NSString *string);
extern NSString *NSStringFromPFPoint(PFPoint point);
extern CGPoint CGPointMakeNormalizedPoint(CGPoint point, STFloat32 distance);
extern PFAxisDirection PFAxisDirectionMake(STFloat32 fromCoordinate, STFloat32 toCoordinate, BOOL sensitive);
extern PFAxisDirection PFDirectionMakeXAxis(CGPoint fromPoint, CGPoint toPoint);
extern PFAxisDirection PFDirectionMakeYAxis(CGPoint fromPoint, CGPoint toPoint);
extern PFAxisDirection PFDirectionMakeXAxisSensitive(CGPoint fromPoint, CGPoint toPoint);
extern PFAxisDirection PFDirectionMakeYAxisSensitive(CGPoint fromPoint, CGPoint toPoint);
================================================
FILE: STKitDemo/Classes/3rdLibs/SphereView/PFGoldenSectionSpiral.m
================================================
//This file is part of SphereView.
//
//SphereView is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//SphereView is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with SphereView. If not, see <http://www.gnu.org/licenses/>.
#import "PFGoldenSectionSpiral.h"
PFMatrix const PFMatrixZero = {0,0,{{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}}};
@implementation PFGoldenSectionSpiral
+ (NSArray *)sphere:(NSInteger)n {
NSMutableArray* result = [NSMutableArray arrayWithCapacity:n];
STFloat32 N = n;
STFloat32 inc = M_PI * (3.0f - sqrt(5.0f));
STFloat32 off = 2.0f / N;
for (NSInteger k = 0; k < N; k ++) {
STFloat32 y = k * off - 1.0f + (off / 2.0f);
STFloat32 r = sqrt(1.0f - y*y);
STFloat32 phi = k * inc;
PFPoint point = PFPointMake(cos(phi)*r, y, sin(phi)*r);
[result addObject:NSStringFromPFPoint(point)];
}
return result;
}
@end
extern PFRadian PFRadianMake(STFloat32 grades) {
return ((STFloat32)(M_PI * grades) / 180.0f);
}
extern PFMatrix PFMatrixTransform3DMakeFromPFPoint(PFPoint point) {
STFloat32 pointRef[1][4] = {{point.x, point.y, point.z, 1.0f}};
PFMatrix matrix = PFMatrixMakeFromArray(1, 4, * pointRef);
return matrix;
}
extern PFMatrix PFMatrixTransform3DMakeTranslation(PFPoint point) {
STFloat32 T[4][4] = {
{1.0f, 0.f, 0.f, 0.f},
{0.f, 1.f, 0.f, 0.f},
{0.f, 0.f, 1.f, 0.f},
{point.x, point.y, point.z, 1.0f}
};
PFMatrix matrix = PFMatrixMakeFromArray(4, 4, *T);
return matrix;
}
extern PFMatrix PFMatrixTransform3DMakeXRotation(PFRadian angle) {
STFloat32 c = cos(PFRadianMake(angle));
STFloat32 s = sin(PFRadianMake(angle));
STFloat32 T[4][4] = {
{1.f, 0.f, 0.f, 0.f},
{0.f, c, s, 0.f},
{0.f, -s, c, 0.f},
{0.f, 0.f, 0.f, 1.f}
};
PFMatrix matrix = PFMatrixMakeFromArray(4, 4, *T);
return matrix;
}
extern PFMatrix PFMatrixTransform3DMakeXRotationOnPoint(PFPoint point, PFRadian angle) {
PFMatrix T = PFMatrixTransform3DMakeTranslation(PFPointMake(-point.x, -point.y, -point.z));
PFMatrix R = PFMatrixTransform3DMakeXRotation(angle);
PFMatrix T1 = PFMatrixTransform3DMakeTranslation(point);
return PFMatrixMultiply(PFMatrixMultiply(T, R), T1);
}
extern PFMatrix PFMatrixTransform3DMakeYRotation(PFRadian angle) {
STFloat32 c = cos(PFRadianMake(angle));
STFloat32 s = sin(PFRadianMake(angle));
STFloat32 T[4][4] = {
{c, 0, -s, 0},
{0, 1, 0, 0},
{s, 0, c, 0},
{0, 0, 0, 1}
};
PFMatrix matrix = PFMatrixMakeFromArray(4, 4, *T);
return matrix;
}
extern PFMatrix PFMatrixTransform3DMakeYRotationOnPoint(PFPoint point, PFRadian angle) {
PFMatrix T = PFMatrixTransform3DMakeTranslation(PFPointMake(-point.x, -point.y, -point.z));
PFMatrix R = PFMatrixTransform3DMakeYRotation(angle);
PFMatrix T1 = PFMatrixTransform3DMakeTranslation(point);
return PFMatrixMultiply(PFMatrixMultiply(T, R), T1);
}
extern PFMatrix PFMatrixTransform3DMakeZRotation(PFRadian angle) {
STFloat32 c = cos(PFRadianMake(angle));
STFloat32 s = sin(PFRadianMake(angle));
STFloat32 T[4][4] = {
{c, s, 0.0f, 0.0f},
{-s, c, 0.0f, 0.0f},
{0,0.0f,0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}
};
PFMatrix matrix = PFMatrixMakeFromArray(4, 4, *T);
return matrix;
}
extern PFMatrix PFMatrixTransform3DMakeZRotationOnPoint(PFPoint point, PFRadian angle) {
PFMatrix T = PFMatrixTransform3DMakeTranslation(PFPointMake(-point.x, -point.y, -point.z));
PFMatrix R = PFMatrixTransform3DMakeZRotation(angle);
PFMatrix T1 = PFMatrixTransform3DMakeTranslation(point);
return PFMatrixMultiply(PFMatrixMultiply(T, R), T1);
}
extern PFMatrix PFMatrixMake(NSInteger m, NSInteger n) {
PFMatrix matrix = PFMatrixZero;
matrix.m = m;
matrix.n = n;
for (NSInteger i = 0; i < m; i ++){
for(NSInteger j = 0; j < n; j ++){
matrix.data[i][j] = (STFloat32)0.0f;
}
}
return matrix;
}
extern PFMatrix PFMatrixMakeFromArray(NSInteger m, NSInteger n, STFloat32 *data) {
PFMatrix matrix = PFMatrixMake(m, n);
for (NSInteger i = 0; i < m; i ++) {
STFloat32 *t = data+(i*sizeof(STFloat32));
for(NSInteger j = 0; j < n; j++) {
matrix.data[i][j] = *(t+j);
}
}
return matrix;
}
extern PFMatrix PFMatrixMakeIdentity(NSInteger m, NSInteger n) {
PFMatrix matrix = PFMatrixMake(m, n);
for (NSInteger i = 0; i < m; i++){
matrix.data[i][i] = 1.0f;
}
return matrix;
}
extern PFMatrix PFMatrixMultiply(PFMatrix A, PFMatrix B) {
PFMatrix R = PFMatrixMake(A.m, B.n);
for(NSInteger i = 0; i < A.m; i++){
for(NSInteger j = 0; j < B.n; j++){
for(NSInteger k = 0; k < A.n; k++){
R.data[i][j] += (A.data[i][k] * B.data[k][j]);
}
}
}
return R;
}
extern NSString *NSStringFromPFMatrix(PFMatrix matrix) {
NSMutableString *str = [NSMutableString string];
[str appendString:@"{"];
for(NSInteger i=0; i<matrix.m; i++){
[str appendString:@"\n{"];
for(NSInteger j=0; j<matrix.n; j++){
[str appendFormat:@"%f",matrix.data[i][j]];
if (j+1 < matrix.n) {
[str appendString:@","];
}
}
[str appendString:@"}"];
if (i+1 < matrix.m) {
[str appendString:@","];
}
}
[str appendString:@"\n}"];
return str;
}
extern PFPoint PFPointMake(STFloat32 x, STFloat32 y, STFloat32 z) {
PFPoint p;
p.x = x;
p.y = y;
p.z = z;
return p;
}
extern PFPoint PFPointMakeFromMatrix(PFMatrix matrix) {
return PFPointMake(matrix.data[0][0], matrix.data[0][1], matrix.data[0][2]);
}
extern PFPoint PFPointFromString(NSString *string) {
PFPoint p;
NSArray *temp = [string componentsSeparatedByString:@","];
if (temp.count > 0) {
p.x = [temp[0] floatValue];
}
if (temp.count > 1) {
p.y = [temp[1] floatValue];
}
if (temp.count > 2) {
p.z = [temp[2] floatValue];
}
return p;
}
extern NSString *NSStringFromPFPoint(PFPoint point) {
return [NSString stringWithFormat:@"%@,%@,%@", @(point.x), @(point.y), @(point.z)];
}
#pragma mark -
#pragma mark CGPoint methods
extern CGPoint CGPointMakeNormalizedPoint(CGPoint point, STFloat32 distance) {
return CGPointMake(point.x * 1.0f / distance, point.y * 1.0f / distance);
}
extern PFAxisDirection PFAxisDirectionMake(STFloat32 fromCoordinate, STFloat32 toCoordinate, BOOL sensitive) {
PFAxisDirection direction = PFAxisDirectionNone;
STFloat32 distance = fabs(fromCoordinate - toCoordinate);
if (distance > PFAxisDirectionMinimumDistance || sensitive) {
if (fromCoordinate > toCoordinate) {
direction = PFAxisDirectionPositive;
} else if (fromCoordinate < toCoordinate) {
direction = PFAxisDirectionNegative;
}
}
return direction;
}
extern PFAxisDirection PFDirectionMakeXAxis(CGPoint fromPoint, CGPoint toPoint) {
return PFAxisDirectionMake(fromPoint.x, toPoint.x, NO);
}
extern PFAxisDirection PFDirectionMakeYAxis(CGPoint fromPoint, CGPoint toPoint) {
return PFAxisDirectionMake(fromPoint.y, toPoint.y, NO);
}
extern PFAxisDirection PFDirectionMakeXAxisSensitive(CGPoint fromPoint, CGPoint toPoint) {
return PFAxisDirectionMake(fromPoint.x, toPoint.x, YES);
}
extern PFAxisDirection PFDirectionMakeYAxisSensitive(CGPoint fromPoint, CGPoint toPoint) {
return PFAxisDirectionMake(fromPoint.y, toPoint.y, YES);
}
================================================
FILE: STKitDemo/Classes/3rdLibs/SphereView/ZYQSphereView.h
================================================
//
// ZYQSphereView.h
// SphereViewSample
//
// Created by Zhao Yiqi on 13-12-8.
// Copyright (c) 2013年 Zhao Yiqi. All rights reserved.
//
#import "PFGoldenSectionSpiral.h"
@interface ZYQSphereView : UIView {
NSMutableDictionary *pointMap;
CGPoint originalLocationInView;
CGPoint previousLocationInView;
PFAxisDirection lastXAxisDirection;
PFAxisDirection lastYAxisDirection;
CGRect originalSphereViewBounds;
}
@property(nonatomic,assign)BOOL isPanTimerStart;
@property(nonatomic,getter = isTimerStart,readonly)BOOL isTimerStart;
- (void)setItems:(NSArray *)items;
-(void)timerStart;
-(void)timerStop;
@end
================================================
FILE: STKitDemo/Classes/3rdLibs/SphereView/ZYQSphereView.m
================================================
//
// ZYQSphereView.m
// SphereViewSample
//
// Created by Zhao Yiqi on 13-12-8.
// Copyright (c) 2013年 Zhao Yiqi. All rights reserved.
//
#import "ZYQSphereView.h"
#import <QuartzCore/QuartzCore.h>
@interface ZYQSphereView(Private)
- (CGFloat)coordinateForNormalizedValue:(CGFloat)normalizedValue withinRangeOffset:(CGFloat)rangeOffset;
- (void)rotateSphereByAngle:(CGFloat)angle fromPoint:(CGPoint)fromPoint toPoint:(CGPoint)toPoint;
- (void)layoutViews;
- (void)layoutView:(UIView *)view withPoint:(PFPoint)point;
@end
@interface ZYQSphereView (){
CGFloat intervalX;
CGFloat intervalY;
}
@property(nonatomic,strong)NSTimer *timer;
@end
@implementation ZYQSphereView
-(BOOL)isTimerStart{
return [_timer isValid];
}
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
panRecognizer.minimumNumberOfTouches = 1;
[self addGestureRecognizer:panRecognizer];
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(handlePinchGesture:)];
[self addGestureRecognizer:pinchRecognizer];
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(handleRotationGesture:)];
[self addGestureRecognizer:rotationRecognizer];
intervalX = 1.0f;
}
return self;
}
-(void)changeView{
CGPoint normalPoint=self.frame.origin;
CGPoint movePoint=CGPointMake(self.frame.origin.x+intervalX, self.frame.origin.y+intervalY);
[self rotateSphereByAngle:1.0f fromPoint:normalPoint toPoint:movePoint];
}
-(void)timerStart{
if (_timer.isValid) {
[_timer invalidate];
}
self.timer=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(changeView) userInfo:nil repeats:YES];
}
-(void)timerStop{
if (_timer.isValid) {
[_timer invalidate];
}
}
- (void)setItems:(NSArray *)items {
pointMap = [[NSMutableDictionary alloc] init];
NSArray *spherePoints = [PFGoldenSectionSpiral sphere:items.count];
for (NSInteger i=0; i<items.count; i++) {
NSString *pointRep = [spherePoints objectAtIndex:i];
PFPoint point = PFPointFromString(pointRep);
UIView *view = items[i];
view.tag = i;
[self layoutView:view withPoint:point];
[self addSubview:view];
[pointMap setObject:pointRep forKey:@(i)];
}
[self rotateSphereByAngle:1.0f fromPoint:CGPointMake(0.f, 0.f) toPoint:CGPointMake(0.f, 1.0f)];
}
- (void)setFrame:(CGRect)pFrame {
[super setFrame:pFrame];
originalSphereViewBounds = self.bounds;
}
#pragma mark -
#pragma mark UIGestureRecognizer methods
- (void)handlePanGesture:(UIPanGestureRecognizer *)panRecognizer {
switch (panRecognizer.state) {
case UIGestureRecognizerStateBegan:
originalLocationInView = [panRecognizer locationInView:self];
previousLocationInView = originalLocationInView;
break;
case UIGestureRecognizerStateChanged: {
CGPoint touchPoint = [panRecognizer locationInView:self];
CGPoint normalizedTouchPoint = CGPointMakeNormalizedPoint(touchPoint, self.frame.size.width);
CGPoint normalizedPreviousTouchPoint = CGPointMakeNormalizedPoint(previousLocationInView, self.frame.size.width);
CGPoint normalizedOriginalTouchPoint = CGPointMakeNormalizedPoint(originalLocationInView, self.frame.size.width);
// Touch direction handling
PFAxisDirection xAxisDirection = PFDirectionMakeXAxisSensitive(normalizedPreviousTouchPoint, normalizedTouchPoint);
if (xAxisDirection != lastXAxisDirection && xAxisDirection != PFAxisDirectionNone) {
lastXAxisDirection = xAxisDirection;
originalLocationInView = CGPointMake(touchPoint.x, previousLocationInView.y);
}
PFAxisDirection yAxisDirection = PFDirectionMakeYAxisSensitive(normalizedPreviousTouchPoint, normalizedTouchPoint);
if (yAxisDirection != lastYAxisDirection && yAxisDirection != PFAxisDirectionNone) {
lastYAxisDirection = yAxisDirection;
originalLocationInView = CGPointMake(previousLocationInView.x, touchPoint.y);
}
previousLocationInView = touchPoint;
intervalX=normalizedTouchPoint.x < normalizedOriginalTouchPoint.x ? -1.0f : 1.f;
intervalY=normalizedTouchPoint.y < normalizedOriginalTouchPoint.y ? -1.0f : 1.f;
// Sphere rotation
[self rotateSphereByAngle:1.0f fromPoint:normalizedOriginalTouchPoint toPoint:normalizedTouchPoint];
}
break;
default:
break;
}
if (_isPanTimerStart) {
[self timerStart];
}
}
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinchRecognizer {
static CGRect InitialSphereViewBounds;
UIView *view = pinchRecognizer.view;
if (pinchRecognizer.state == UIGestureRecognizerStateBegan){
InitialSphereViewBounds = view.bounds;
}
CGFloat factor = pinchRecognizer.scale;
CGAffineTransform scaleTransform = CGAffineTransformScale(CGAffineTransformIdentity, factor, factor);
CGRect sphereFrame = CGRectApplyAffineTransform(InitialSphereViewBounds, scaleTransform);
CGRect screenFrame = [UIScreen mainScreen].bounds;
if ((sphereFrame.size.width > screenFrame.size.width
&& sphereFrame.size.height > screenFrame.size.height)
|| (sphereFrame.size.width < originalSphereViewBounds.size.width
&& sphereFrame.size.height < originalSphereViewBounds.size.height)) {
return;
}
view.bounds = sphereFrame;
[self layoutViews];
}
- (void)handleRotationGesture:(UIRotationGestureRecognizer *)rotationRecognizer {
static CGFloat LastSphereRotationAngle;
if (rotationRecognizer.state == UIGestureRecognizerStateEnded) {
LastSphereRotationAngle = 0;
return;
}
PFAxisDirection rotationDirection;
CGFloat rotation = rotationRecognizer.rotation;
if (rotation > LastSphereRotationAngle) {
rotationDirection = PFAxisDirectionPositive;
} else {
rotationDirection = PFAxisDirectionNegative;
}
rotation = fabs(rotation) * rotationDirection;
NSArray *subviews = self.subviews;
for (NSInteger i = 0; i<subviews.count; i++) {
UIView *view = [subviews objectAtIndex:i];
NSNumber *key = @(i);
PFPoint point = PFPointFromString([pointMap objectForKey:key]);
PFPoint aroundPoint = PFPointMake(0.0f, 0.0f, 0.0f);
PFMatrix coordinate = PFMatrixTransform3DMakeFromPFPoint(point);
PFMatrix transform = PFMatrixTransform3DMakeZRotationOnPoint(aroundPoint, rotation);
point = PFPointMakeFromMatrix(PFMatrixMultiply(coordinate, transform));
[pointMap setObject:NSStringFromPFPoint(point) forKey:key];
[self layoutView:view withPoint:point];
}
LastSphereRotationAngle = rotationRecognizer.rotation;
}
- (void)handleTapGesture:(UITapGestureRecognizer *)tapRecognizer {
if ([self isTimerStart]) {
[self timerStop];
} else{
[self timerStart];
}
}
#pragma mark -
#pragma mark Animation methods
- (void)rotateSphereByAngle:(CGFloat)angle fromPoint:(CGPoint)fromPoint toPoint:(CGPoint)toPoint {
NSArray *subviews = self.subviews;
for (NSInteger i = 0; i < subviews.count; i++) {
UIView *view = [subviews objectAtIndex:i];
NSNumber *key = @(i);
PFPoint point = PFPointFromString([pointMap objectForKey:key]);
PFPoint aroundPoint = PFPointMake(0.0f, 0.0f, 0.0f);
PFMatrix coordinate = PFMatrixTransform3DMakeFromPFPoint(point);
PFMatrix transform = PFMatrixMakeIdentity(4, 4);
PFAxisDirection xAxisDirection = PFDirectionMakeXAxis(fromPoint, toPoint);
if (xAxisDirection != PFAxisDirectionNone) {
transform = PFMatrixMultiply(transform, PFMatrixTransform3DMakeYRotationOnPoint(aroundPoint, xAxisDirection * -angle));
}
PFAxisDirection yAxisDirection = PFDirectionMakeYAxis(fromPoint, toPoint);
if (yAxisDirection != PFAxisDirectionNone) {
transform = PFMatrixMultiply(transform, PFMatrixTransform3DMakeXRotationOnPoint(aroundPoint, yAxisDirection * angle));
}
point = PFPointMakeFromMatrix(PFMatrixMultiply(coordinate, transform));
[pointMap setObject:NSStringFromPFPoint(point) forKey:key];
[self layoutView:view withPoint:point];
}
}
- (CGFloat)coordinateForNormalizedValue:(CGFloat)normalizedValue withinRangeOffset:(CGFloat)rangeOffset {
CGFloat half = rangeOffset / 2.f;
CGFloat coordinate = fabs(normalizedValue) * half;
if (normalizedValue > 0) {
coordinate += half;
} else {
coordinate = half - coordinate;
}
return coordinate;
}
- (void)layoutView:(UIView *)view withPoint:(PFPoint)point {
CGFloat viewSize = CGRectGetWidth(view.frame);
CGFloat width = CGRectGetWidth(self.frame) - viewSize * 2.0f;
CGFloat x = [self coordinateForNormalizedValue:point.x withinRangeOffset:width];
CGFloat y = [self coordinateForNormalizedValue:point.y withinRangeOffset:width];
view.center = CGPointMake(x + viewSize, y + viewSize);
CGFloat z = [self coordinateForNormalizedValue:point.z withinRangeOffset:1.0f];
view.transform = CGAffineTransformScale(CGAffineTransformIdentity, z, z);
view.layer.zPosition = z;
}
- (void)layoutViews {
NSArray *subviews = self.subviews;
for (NSInteger i = 0; i < subviews.count; i ++) {
UIView *view = [subviews objectAtIndex:i];
NSNumber *key = @(i);
PFPoint point = PFPointFromString([pointMap objectForKey:key]);
[self layoutView:view withPoint:point];
}
}
- (void)dealloc {
if ([_timer isValid]) {
[_timer invalidate];
}
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STAlertView.h
================================================
//
// STAlertView.h
// STKitDemo
//
// Created by SunJiangting on 14-8-28.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface STAlertView : UIView
- (instancetype)initWithMenuTitles:(NSString *)menuTitle, ... NS_REQUIRES_NIL_TERMINATION;
- (NSInteger)showInView:(UIView *)view animated:(BOOL)animated;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STAlertView.m
================================================
//
// STAlertView.m
// STKitDemo
//
// Created by SunJiangting on 14-8-28.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STAlertView.h"
#import <STKit/STKit.h>
@interface _STAlertViewCell : UITableViewCell
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIView *separatorView;
@end
const CGFloat _STAlertViewCellHeight = 45;
@implementation _STAlertViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.frame = CGRectMake(0, 0, 320, _STAlertViewCellHeight);
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.titleLabel.textColor = [UIColor darkGrayColor];
self.titleLabel.highlightedTextColor = [UIColor whiteColor];
self.titleLabel.font = [UIFont systemFontOfSize:17.];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLabel];
self.separatorView = [[UIView alloc] initWithFrame:CGRectZero];
[self addSubview:self.separatorView];
}
return self;
}
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
self.separatorView.frame = CGRectMake(0, CGRectGetHeight(frame) - STOnePixel(), CGRectGetWidth(frame), STOnePixel());
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
self.separatorView.backgroundColor = [UIColor colorWithRed:0x99/255. green:0x99/255. blue:0x99/255. alpha:1.0];
}
@end
@interface STAlertView () <UITableViewDataSource, UITableViewDelegate, UIGestureRecognizerDelegate> {
BOOL _shouldContinue;
NSInteger _dismissedIndex;
}
@property(nonatomic, strong) NSMutableArray *dataSource;
@property(nonatomic, weak) UITableView *tableView;
@property(nonatomic, weak) UIView *backgroundView;
@property(nonatomic, weak) UIView *contentView;
@property(nonatomic, strong) UIView *hitTestView;
@end
@implementation STAlertView
- (instancetype)initWithMenuTitles:(NSString *)menuTitle, ... NS_REQUIRES_NIL_TERMINATION {
NSMutableArray *dataSource = [NSMutableArray arrayWithCapacity:1];
NSString *title = nil;
va_list args;
if (menuTitle) {
[dataSource addObject:menuTitle];
va_start(args, menuTitle);
while ((title = va_arg(args, NSString *))) {
[dataSource addObject:title];
}
va_end(args);
}
self = [super initWithFrame:CGRectZero];
if (self) {
self.dataSource = dataSource;
CGFloat maxHeight = 240;
const CGFloat footerHeight = 1;
CGFloat height = dataSource.count * _STAlertViewCellHeight + footerHeight;
UIView *backgroundView = [[UIView alloc] initWithFrame:self.bounds];
backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
backgroundView.backgroundColor = [UIColor blackColor];
[self addSubview:backgroundView];
self.backgroundView = backgroundView;
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, STOnePixel(), 0, MIN(height, maxHeight))];
contentView.clipsToBounds = YES;
[self addSubview:contentView];
self.contentView = contentView;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissActionFired:)];
tapGesture.numberOfTapsRequired = 1;
tapGesture.delegate = self;
[self.backgroundView addGestureRecognizer:tapGesture];
UITableView *tableView = [[UITableView alloc] initWithFrame:self.contentView.bounds style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundView = nil;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[tableView registerClass:[_STAlertViewCell class] forCellReuseIdentifier:@"Identifier"];
[self.contentView addSubview:tableView];
self.tableView = tableView;
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, footerHeight)];
tableView.tableFooterView.backgroundColor = [UIColor colorWithRed:0xFF/255. green:0x73/255. blue:0 alpha:1.0];
if (height > maxHeight) {
tableView.scrollEnabled = YES;
} else {
tableView.scrollEnabled = NO;
}
__weak STAlertView *weakSelf = self;
self.hitTestView = [[UIView alloc] init];
self.hitTestView.hitTestBlock = ^(CGPoint point, UIEvent *event, BOOL *returnSuper) {
CGRect contentRect = [weakSelf.superview convertRect:weakSelf.frame toView:nil];
if (!CGPointInRect(point, contentRect)){
[weakSelf dismissActionFired:nil];
*returnSuper = YES;
}
return (UIView *)nil;
};
self.hitTestView.backgroundColor = [UIColor clearColor];
}
return self;
}
- (NSInteger)showInView:(UIView *)view animated:(BOOL)animated {
self.hitTestView.frame = [UIScreen mainScreen].bounds;
[[UIApplication sharedApplication].delegate.window addSubview:self.hitTestView];
//
{
self.tableView.contentInset = UIEdgeInsetsZero;
if (!view) {
view = [UIApplication sharedApplication].keyWindow;
}
[view addSubview:self];
self.frame = view.bounds;
CGRect frame = self.contentView.frame;
frame.size.width = CGRectGetWidth(view.bounds);
self.backgroundView.alpha = 0.0;
CGRect fromRect = frame, targetRect = frame;
fromRect.size.height = 0;
self.contentView.frame = fromRect;
void (^animation)(void) = ^(void) {
self.backgroundView.alpha = 0.5;
self.contentView.frame = targetRect;
};
void (^completion)(BOOL) = ^(BOOL finished) {
};
if (animated) {
[UIView animateWithDuration:0.35 animations:animation completion:completion];
}
}
while (!_shouldContinue) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
return _dismissedIndex;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return _STAlertViewCellHeight;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
_STAlertViewCell *tableViewCell = [tableView dequeueReusableCellWithIdentifier:@"Identifier"];
tableViewCell.titleLabel.text = self.dataSource[indexPath.row];
return tableViewCell;
}
- (void)dismissAnimated:(BOOL)animated {
[self _dismissAnimated:animated completion:^(BOOL finished){}];
}
#pragma mark - PrivateMethod
- (void)dismissActionFired:(UITapGestureRecognizer *)sender {
_dismissedIndex = -1;
[self _dismissAnimated:YES completion:^(BOOL finished){}];
}
- (void)_dismissAnimated:(BOOL)animated completion:(void (^)(BOOL))_completion {
self.backgroundView.alpha = 0.5;
CGRect fromRect = self.contentView.frame, targetRect = self.contentView.frame;
self.contentView.frame = fromRect;
targetRect.size.height = 0;
void (^animation)(void) = ^(void) {
self.backgroundView.alpha = 0.0;
self.contentView.frame = targetRect;
};
void (^completion)(BOOL) = ^(BOOL finished) {
_shouldContinue = YES;
if (_completion) {
_completion(finished);
}
[self removeFromSuperview];
[self.hitTestView removeFromSuperview];
};
if (animated) {
[UIView animateWithDuration:0.35 animations:animation completion:completion];
} else {
animation();
completion(YES);
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
_dismissedIndex = indexPath.row;
[self dismissAnimated:YES];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
CGPoint touchedPoint = [gestureRecognizer locationInView:self];
if (touchedPoint.y < CGRectGetMaxY(self.contentView.frame) && touchedPoint.y > CGRectGetMinX(self.contentView.frame)) {
return NO;
}
return YES;
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDCardTransitionDelegate.h
================================================
//
// STDCardTransitionDelegate.h
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDTransitionDelegate.h"
@interface STDCardTransitionDelegate : STDTransitionDelegate
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDCardTransitionDelegate.m
================================================
//
// STDCardTransitionDelegate.m
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDCardTransitionDelegate.h"
@implementation STDCardTransitionDelegate
- (BOOL)navigationController:(STNavigationController *)navigationController
shouldBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
return YES;
}
- (void)navigationController:(STNavigationController *)navigationController
willBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
UIView *fromView = transitionContext.fromView, *toView = transitionContext.toView, *transitionView = transitionContext.transitionView;
STViewControllerTransitionType transitionType = transitionContext.transitionType;
fromView.layer.transform = toView.layer.transform = CATransform3DIdentity;
fromView.left = 0;
if (transitionType == STViewControllerTransitionTypePush) {
toView.left = CGRectGetWidth(transitionView.bounds);
} else {
toView.left = - CGRectGetWidth(transitionView.bounds);;
}
}
- (void)navigationController:(STNavigationController *)navigationController
transitingWithContext:(STNavigationControllerTransitionContext *)transitionContext {
UIView *fromView = transitionContext.fromView, *toView = transitionContext.toView, *transitionView = transitionContext.transitionView;
CGFloat completion = transitionContext.completion;
STViewControllerTransitionType transitionType = transitionContext.transitionType;
[self _transformAppliedToFromView:fromView andToView:toView withTransitionView:transitionView completion:completion transitionType:transitionType];
}
- (void)navigationController:(STNavigationController *)navigationController didEndTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
UIView *fromView = transitionContext.fromView, *toView = transitionContext.toView, *transitionView = transitionContext.transitionView;
STViewControllerTransitionType transitionType = transitionContext.transitionType;
fromView.layer.transform = toView.layer.transform = CATransform3DIdentity;
toView.left = 0;
if (transitionType == STViewControllerTransitionTypePush) {
fromView.left = -CGRectGetWidth(transitionView.bounds);
} else {
fromView.left = CGRectGetWidth(transitionView.bounds);
}
}
- (void)_transformAppliedToFromView:(UIView *)fromView
andToView:(UIView *)toView
withTransitionView:(UIView *)transitionView
completion:(CGFloat)completion
transitionType:(STViewControllerTransitionType)transitionType {
UIView *leftView, *rightView;
CGFloat width = CGRectGetWidth(transitionView.bounds);
CGFloat leftAngel, leftHeight, leftX, rightAngel, rightHeight, rightX,currentPanOffset, leftPanOffset, rightPanOffset;
BOOL leftXAxis, rightXAxis;
CGFloat leftViewOffset = 0, rightViewOffset = width;
if (transitionType == STViewControllerTransitionTypePush) {
leftView = fromView, rightView = toView;
currentPanOffset = width * completion;
leftPanOffset = (currentPanOffset - leftViewOffset), rightPanOffset = (currentPanOffset - rightViewOffset);
leftX = - completion * width;
rightX = width - completion * width;
} else {
leftView = toView, rightView = fromView;
currentPanOffset = width - width * completion;
leftPanOffset = (currentPanOffset - leftViewOffset), rightPanOffset = (currentPanOffset - rightViewOffset);
leftX = completion * width - width;
rightX = completion * width;
}
leftAngel = leftPanOffset / width, rightAngel = rightPanOffset / width;
CGFloat heightOffset = 80;
leftHeight = heightOffset * (leftAngel < 0 ? -leftAngel : leftAngel), rightHeight = heightOffset * (rightAngel < 0 ? -rightAngel : rightAngel);
leftXAxis = (currentPanOffset > leftViewOffset), rightXAxis = (currentPanOffset > rightViewOffset);
leftView.layer.transform = CATransform3DIdentity;
leftView.left = leftX;
leftView.layer.transform = [self _transform3DWithAngle:leftAngel height:leftHeight xAxis:leftXAxis];
rightView.layer.transform = CATransform3DIdentity;
rightView.left = rightX;
rightView.layer.transform = [self _transform3DWithAngle:rightAngel height:rightHeight xAxis:rightXAxis];
}
- (CATransform3D)_transform3DWithAngle:(CGFloat)angle
height:(CGFloat)height
xAxis:(BOOL)axis {
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/-500;
CGFloat x = axis ? 1 : -1;
return CATransform3DRotate(transform, angle, x, 1, 0);
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDCoreDataManager.h
================================================
//
// STDCoreDataManager.h
// STKitDemo
//
// Created by SunJiangting on 15/8/11.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <STKit/STKit.h>
@interface STDCoreDataManager : NSObject
+ (STCoreDataManager *)chatDataManager;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDCoreDataManager.m
================================================
//
// STDCoreDataManager.m
// STKitDemo
//
// Created by SunJiangting on 15/8/11.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDCoreDataManager.h"
@implementation STDCoreDataManager
static STCoreDataManager *_chatDataManager;
+ (STCoreDataManager *)chatDataManager {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSString *modelName = @"STDModel";
NSString *path = [STDocumentDirectory() stringByAppendingFormat:@"%@.sqlite", modelName];
_chatDataManager = [[STCoreDataManager alloc] initWithModelName:modelName dbFilePath:path];
});
return _chatDataManager;
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDLoadingView.h
================================================
//
// STDLoadingView.h
// STKitDemo
//
// Created by SunJiangting on 15-4-2.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface STDLoadingView : UIView
@property(nonatomic) CGFloat completion;
- (void)startAnimating;
- (BOOL)isAnimating;
- (void)stopAnimating;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDLoadingView.m
================================================
//
// STDLoadingView.m
// STKitDemo
//
// Created by SunJiangting on 15-4-2.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDLoadingView.h"
#import <STKit/STKit.h>
@interface STDLoadingView ()
@property(nonatomic, strong) CAShapeLayer *shapeLayer;
@property(nonatomic, strong) UIImageView *imageView;
@end
@implementation STDLoadingView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self _commonInitialize];
}
return self;
}
- (void)awakeFromNib {
[super awakeFromNib];
[self _commonInitialize];
}
- (void)_commonInitialize {
self.backgroundColor = [UIColor clearColor];
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.frame = self.bounds;
shapeLayer.fillColor = [UIColor st_colorWithRGB:0xFF7300].CGColor;
[self.layer addSublayer:shapeLayer];
self.shapeLayer = shapeLayer;
self.imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
NSMutableArray *images = [NSMutableArray arrayWithCapacity:8];
for (NSInteger i = 1; i <= 8; i ++) {
NSString *imageName = [NSString stringWithFormat:@"%02ld", (long)i];
UIImage *image = [UIImage imageNamed:imageName];
if (image) {
[images addObject:image];
}
}
self.imageView.image = [images firstObject];
self.imageView.animationImages = images;
self.imageView.animationDuration = 0.5;
self.imageView.hidden = YES;
[self addSubview:self.imageView];
self.completion = 0;
}
- (void)setCompletion:(CGFloat)completion {
_completion = completion;
if (completion < 1 && !self.imageView.isAnimating) {
[self _layoutWithCompletion:completion];
} else {
[self _layoutWithCompletion:1];
self.imageView.frame = CGRectMake(self.inCenterX - 30, self.height - 60, 60, 60);
self.imageView.hidden = NO;
}
}
- (void)stopAnimating {
self.imageView.hidden = YES;
[self.imageView stopAnimating];
}
- (void)startAnimating {
if (!self.imageView.isAnimating) {
[self.imageView startAnimating];
}
}
- (BOOL)isAnimating {
return self.imageView.isAnimating;
}
- (void)_layoutWithCompletion:(CGFloat)completion {
CGFloat width = 0, height = 0;
self.imageView.hidden = YES;
// 先从5到20----然后从20----40------>40
if (completion < 0.3) {
CGFloat phaseCompletion = completion / 0.3;
width = 3 + phaseCompletion * 12;
height = width;
} else if (completion < 0.7) {
CGFloat phaseCompletion = (completion - 0.3) / 0.4;
width = 15 + phaseCompletion * 5;
height = 15 + phaseCompletion * 30;
} else if (completion < 0.8) {
CGFloat phaseCompletion = (completion - 0.7) / 0.1;
width = 20 + phaseCompletion * 10;
height = 45 - phaseCompletion * 15;
} else {
self.imageView.hidden = NO;
CGFloat phaseCompletion = (completion - 0.8) / 0.2;
width = 30 + phaseCompletion * 30;
height = 30 + phaseCompletion * 30;
}
CGFloat x = (CGRectGetWidth(self.bounds) - width ) / 2;
CGFloat y = CGRectGetHeight(self.bounds) - height;
CGRect rect = CGRectMake(x, y, width, height);
UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:rect];
self.shapeLayer.path = bezierPath.CGPath;
self.imageView.frame = rect;
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDRefreshControl.h
================================================
//
// STDRefreshControl.h
// STKitDemo
//
// Created by SunJiangting on 15-4-2.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
@interface STDRefreshControl : STRefreshControl
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDRefreshControl.m
================================================
//
// TTRefreshControl.m
// STKitDemo
//
// Created by SunJiangting on 15-4-2.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDRefreshControl.h"
#import "STDLoadingView.h"
@interface STDRefreshControl ()
@property(nonatomic, strong) STDLoadingView *loadingView;
@end
@implementation STDRefreshControl
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.loadingView = [[STDLoadingView alloc] initWithFrame:CGRectZero];
[self addSubview:self.loadingView];
self.minimumLoadingDuration = 2.0;
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.loadingView.frame = self.bounds;
}
- (void)scrollViewDidChangeContentOffset:(CGPoint)contentOffset {
CGFloat contentOffsetY = contentOffset.y;
if (contentOffset.y < 0) {
self.loadingView.completion = MIN(ABS(contentOffsetY) / self.threshold, 1);
}
}
- (void)refreshControlDidChangedToState:(STRefreshControlState)refreshControlState {
if (refreshControlState == STRefreshControlStateNormal) {
[self.loadingView stopAnimating];
self.loadingView.completion = 0;
} else if (refreshControlState == STRefreshControlStateLoading) {
self.loadingView.completion = 1.0;
[self.loadingView startAnimating];
}
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDRotateTransitionDelegate.h
================================================
//
// STDRotateTransitionDelegate.h
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDTransitionDelegate.h"
@interface STDRotateTransitionDelegate : STDTransitionDelegate
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDRotateTransitionDelegate.m
================================================
//
// STDRotateTransitionDelegate.m
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDRotateTransitionDelegate.h"
@implementation STDRotateTransitionDelegate
- (BOOL)navigationController:(STNavigationController *)navigationController
shouldBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
return YES;
}
- (void)navigationController:(STNavigationController *)navigationController
willBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
UIView *targetView;
CGFloat originAngle;
if (transitionContext.transitionType == STViewControllerTransitionTypePop) {
targetView = transitionContext.fromView;
originAngle = 0;
} else {
targetView = transitionContext.toView;
originAngle = M_PI_2;
}
targetView.anchorPoint = CGPointMake(0.0, 1.0);
targetView.layer.transform = CATransform3DMakeRotation(originAngle, 0.0, .0, 1.0);
}
- (void)navigationController:(STNavigationController *)navigationController
transitingWithContext:(STNavigationControllerTransitionContext *)transitionContext {
CGFloat completion = transitionContext.completion;
UIView *fromView = transitionContext.fromView, *toView = transitionContext.toView;
STViewControllerTransitionType transitionType = transitionContext.transitionType;
UIView *targetView;
if (transitionType == STViewControllerTransitionTypePop) {
targetView = fromView;
} else {
targetView = toView;
completion = (1.0 - completion);
}
targetView.layer.transform = CATransform3DMakeRotation(M_PI_2 * completion, 0.0, .0, 1.0);
}
- (void)navigationController:(STNavigationController *)navigationController
didEndTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
UIView *fromView = transitionContext.fromView, *toView = transitionContext.toView;
fromView.anchorPoint = CGPointMake(0.5, 0.5);
fromView.layer.transform = CATransform3DIdentity;
toView.anchorPoint = CGPointMake(0.5, 0.5);
toView.layer.transform = CATransform3DIdentity;
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDScrollViewController.h
================================================
//
// STDScrollViewController.h
// STKitDemo
//
// Created by SunJiangting on 15-4-7.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
@interface STDScrollView : UIView
@property(nonatomic, strong) UIView *headerView;
@end
@interface STDScrollViewController : STDViewController
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDScrollViewController.m
================================================
//
// STDScrollViewController.m
// STKitDemo
//
// Created by SunJiangting on 15-4-7.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDScrollViewController.h"
#import "STDRefreshControl.h"
#import <objc/runtime.h>
@interface UIView (STDWebViewHeader)
@property(nonatomic) CGFloat headerOffset;
@end
@implementation UIView (STDWebViewHeader)
static NSString *const STDViewHeaderOffsetKey = @"STDViewHeaderOffsetKey";
- (void)setHeaderOffset:(CGFloat)headerOffset {
objc_setAssociatedObject(self, (__bridge const void *)(STDViewHeaderOffsetKey), @(headerOffset), OBJC_ASSOCIATION_COPY_NONATOMIC);
}
- (CGFloat)headerOffset {
NSNumber *value = objc_getAssociatedObject(self, (__bridge const void *)(STDViewHeaderOffsetKey));
return [value floatValue];
}
@end
@interface STDWebView : UIWebView
@property(nonatomic, strong) UIView *webHeaderView;
@end
@implementation STDWebView
- (void)setWebHeaderView:(UIView *)webHeaderView {
if (_webHeaderView) {
[_webHeaderView removeFromSuperview];
}
_webHeaderView = webHeaderView;
[self.scrollView addSubview:webHeaderView];
[self.scrollView.subviews enumerateObjectsUsingBlock:^(UIView *subview, NSUInteger idx, BOOL *stop) {
if (subview != webHeaderView) {
subview.top += (webHeaderView.height - subview.headerOffset);
subview.headerOffset = webHeaderView.height;
}
}];
}
- (void)layoutSubviews {
[super layoutSubviews];
}
@end
@interface STDScrollViewController () <UIWebViewDelegate, UIScrollViewDelegate>
@property(nonatomic, strong) UIView *headerView;
@property(nonatomic, strong) STDWebView *webView;
@property(nonatomic, strong) STScrollDirector *scrollDirector;
@end
@implementation STDScrollViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.hidesBottomBarWhenPushed = YES;
self.edgesForExtendedLayout = UIRectEdgeNone;
self.scrollDirector = [[STScrollDirector alloc] init];
STDRefreshControl *refreshControl = [[STDRefreshControl alloc] initWithFrame:CGRectMake(0, 0, 200, 76)];
refreshControl.threshold = 76;
self.scrollDirector.refreshControl = refreshControl;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"WebViewHeaderView";
self.headerView = [[UIView alloc] initWithFrame:self.view.bounds];
self.headerView.height = 200;
self.headerView.backgroundColor = [UIColor redColor];
self.webView = [[STDWebView alloc] initWithFrame:self.view.bounds];
// CGRectMake(0, self.headerView.bottom, self.view.width, self.view.height - self.headerView.bottom)];
self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.webView.webHeaderView = self.headerView;
// [self.webView.scrollView.panGestureRecognizer addTarget:self action:@selector(_webScrollViewPanActionFired:)];
// self.webView.delegate = self;
[self.webView.scrollView addSubview:self.headerView];
self.webView.scrollView.delegate = self;
[self.view addSubview:self.webView];
// [self.view addSubview:self.headerView];
// self.scrollDirector.scrollView = self.webView.scrollView;
// [self.scrollDirector.refreshControl addTarget:self.webView action:@selector(reload) forControlEvents:UIControlEventValueChanged];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://suenblog.duapp.com"]]];
}
- (void)_webScrollViewPanActionFired:(UIPanGestureRecognizer *)panGestureRecognizer {
if (panGestureRecognizer.state != UIGestureRecognizerStateChanged) {
return;
}
UIScrollView *scrollView = self.webView.scrollView;
CGPoint contentOffset = scrollView.contentOffset;
CGFloat offsetY = contentOffset.y;
if (offsetY <= 0) {
self.webView.top = - offsetY + self.headerView.height;
self.headerView.top = - offsetY;
} else if (offsetY >= self.headerView.height) {
self.webView.top = 0;
self.webView.height = self.view.height;
self.headerView.top = - offsetY;
contentOffset.y = offsetY - self.headerView.height;
} else {
self.webView.top = self.headerView.height - offsetY;
self.headerView.top = - offsetY;
self.webView.height = self.view.height - self.headerView.bottom;
contentOffset.y = 0;
}
scrollView.contentOffset = contentOffset;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
return;
CGPoint contentOffset = scrollView.contentOffset;
CGFloat offsetY = contentOffset.y;
if (offsetY <= 0) {
self.webView.top = - offsetY + self.headerView.height;
self.headerView.top = - 2 * offsetY;
// contentOffset.y = 0;
} else if (offsetY >= self.headerView.height) {
self.webView.top = 0;
self.webView.height = self.view.height;
self.headerView.top = - offsetY;
} else {
self.webView.top = self.headerView.height - offsetY;
self.headerView.top = - 2 * offsetY;
self.webView.height = self.view.height - self.headerView.bottom;
}
}
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
return YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[self.scrollDirector.refreshControl endRefreshing];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[self.scrollDirector.refreshControl endRefreshing];
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTabBarController.h
================================================
//
// STDTabBarController.h
// STKitDemo
//
// Created by SunJiangting on 14-2-18.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
@interface STDTabBarController : STTabBarController
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTabBarController.m
================================================
//
// STDTabBarController.m
// STKitDemo
//
// Created by SunJiangting on 14-2-18.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDTabBarController.h"
#import "STARootViewController.h"
#import "STDMoreViewController.h"
#import "STDemoViewController.h"
#import "STDServiceViewController.h"
#import "STDSettingViewController.h"
#import "STDCardTransitionDelegate.h"
#import "STDRotateTransitionDelegate.h"
@interface STDTabBarController ()
@end
@implementation STDTabBarController
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
STDemoViewController *controlsViewController = [[STDemoViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *controlsNavigationController = [[STNavigationController alloc] initWithRootViewController:controlsViewController];
controlsNavigationController.st_tabBarItem = [[STTabBarItem alloc] initWithTitle:@"组件"
image:[UIImage imageNamed:@"tab_receipt_normal.png"]
selectedImage:[UIImage imageNamed:@"tab_receipt_highlighted.png"]];
STDServiceViewController *serviceViewController = [[STDServiceViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *serviceNavigationController = [[STNavigationController alloc] initWithRootViewController:serviceViewController];
serviceNavigationController.st_tabBarItem = [[STTabBarItem alloc] initWithTitle:@"服务"
image:[UIImage imageNamed:@"tab_service_normal.png"]
selectedImage:[UIImage imageNamed:@"tab_service_highlighted.png"]];
STDMoreViewController *moreViewController = [[STDMoreViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *moreNavigationController = [[STNavigationController alloc] initWithRootViewController:moreViewController];
moreNavigationController.st_tabBarItem = [[STTabBarItem alloc] initWithTitle:@"我的"
image:[UIImage imageNamed:@"tab_profile_normal.png"]
selectedImage:[UIImage imageNamed:@"tab_profile_highlighted.png"]];
self.viewControllers = @[controlsNavigationController, serviceNavigationController, moreNavigationController];
self.st_sideInteractionArea = STSideInteractiveAreaNone;
self.animatedWhenTransition = ![STDSettingViewController reduceTransitionAnimation];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
if (STGetSystemVersion() < 7) {
self.actualTabBarHeight = 42;
self.tabBar.backgroundImage =
[[UIImage imageNamed:@"tab_bkg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 2, 10, 2) resizingMode:UIImageResizingModeStretch];
}
if (![[[STPersistence standardPersistence] valueForKey:@"STHasEnteredAboutViewController"] boolValue]) {
[self setBadgeValue:@"New" forIndex:2];
}
[self reloadNavigationTransitionDelegate];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadNavigationTransitionDelegate) name:@"STDAllowsCustomNavigationTransitionDidChangeNotification" object:nil];
}
- (void)reloadNavigationTransitionDelegate {
STNavigationController *navigationController = (STNavigationController *)[self.viewControllers firstObject];
if ([navigationController isKindOfClass:[STNavigationController class]]) {
navigationController.delegate = [STDSettingViewController allowsCustomNavigationTransition]?[STDRotateTransitionDelegate sharedDelegate]:nil;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTableViewController.h
================================================
//
// STDTableViewController.h
// STKitDemo
//
// Created by SunJiangting on 13-12-27.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
#import "STDViewController.h"
@interface STDTableViewController : STModelViewController <UITableViewDataSource, UITableViewDelegate>
- (instancetype)initWithStyle:(UITableViewStyle) tableViewStyle;
@property(nonatomic, readonly, strong) UITableView *tableView;
@property(nonatomic, assign) BOOL clearsSelectionOnViewWillAppear;
@property(nonatomic, strong, readonly) STScrollDirector *scrollDirector;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTableViewController.m
================================================
//
// STDTableViewController.m
// STKitDemo
//
// Created by SunJiangting on 13-12-27.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import "STDTableViewController.h"
@interface STDTableViewController ()
@property(nonatomic, strong) UITableView *tableView;
@property(nonatomic, assign) UITableViewStyle tableViewStyle;
@property(nonatomic, strong) STScrollDirector *scrollDirector;
@end
@implementation STDTableViewController
- (instancetype) initWithStyle:(UITableViewStyle)tableViewStyle {
self = [super initWithNibName:nil bundle:nil];
if (self) {
self.tableViewStyle = tableViewStyle;
self.clearsSelectionOnViewWillAppear = YES;
self.scrollDirector = [[STScrollDirector alloc] init];
[self.scrollDirector setTitle:@"下拉可以刷新" forState:STScrollDirectorStateRefreshNormal];
[self.scrollDirector setTitle:@"松手开始刷新" forState:STScrollDirectorStateRefreshReachedThreshold];
[self.scrollDirector setTitle:@"正在刷新..." forState:STScrollDirectorStateRefreshLoading];
[self.scrollDirector setTitle:@"加载更多" forState:STScrollDirectorStatePaginationNormal];
[self.scrollDirector setTitle:@"正在加载更多" forState:STScrollDirectorStatePaginationLoading];
[self.scrollDirector setTitle:@"重新加载" forState:STScrollDirectorStatePaginationFailed];
[self.scrollDirector setTitle:@"没有更多了" forState:STScrollDirectorStatePaginationReachedEnd];
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
return [self initWithStyle:UITableViewStylePlain];
}
- (void)loadView {
[super loadView];
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:self.tableViewStyle];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableView.dataSource = self;
self.tableView.delegate = self;
self.tableView.backgroundView = nil;
self.tableView.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.tableView];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
CGFloat value = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultEdgeOffset"] doubleValue];
if (value == 0) {
value = 80;
[[STPersistence standardPersistence] setValue:@(value) forKey:@"STDNavigationDefaultEdgeOffset"];
}
self.st_maximumInteractivePopEdgeDistance = value;
CGFloat value1 = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultOffset"] floatValue];
if (value1 == 0) {
value1 = 80;
[[STPersistence standardPersistence] setValue:@(value1) forKey:@"STDNavigationDefaultOffset"];
}
self.st_interactivePopTransitionOffset = value1;
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(maximumInteractiveDistanceChanged:)
name:@"STDNavigationDefaultEdgeOffset"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(maximumInteractiveOffsetChanged:)
name:@"STDNavigationDefaultOffset"
object:nil];
self.scrollDirector.scrollView = self.tableView;
[self.scrollDirector.refreshControl addTarget:self action:@selector(_refreshControlActionFired:) forControlEvents:UIControlEventValueChanged];
[self.scrollDirector.paginationControl addTarget:self action:@selector(_paginationControlActionFired:) forControlEvents:UIControlEventValueChanged];
}
- (void)maximumInteractiveDistanceChanged:(id)sender {
self.st_maximumInteractivePopEdgeDistance = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultEdgeOffset"] floatValue];
}
- (void)maximumInteractiveOffsetChanged:(id)sender {
self.st_interactivePopTransitionOffset = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultOffset"] floatValue];
}
- (void)_refreshControlActionFired:(STRefreshControl *)refreshControl {
[self.model loadDataFromRemote];
}
- (void)_paginationControlActionFired:(id) sender {
[self.model loadDataFromPagination];
}
- (void)modelDidFinishLoadData:(STModel *)model {
[super modelDidFinishLoadData:model];
if (model.sourceType == STModelDataSourceTypeRemote) {
[self.scrollDirector.refreshControl endRefreshing];
}
[self _reloadTableFooterView];
[self.tableView reloadData];
}
- (void)modelDidFailedLoadData:(STModel *)model {
[super modelDidFailedLoadData:model];
if (model.sourceType == STModelDataSourceTypeRemote) {
[self.scrollDirector.refreshControl endRefreshing];
} else {
if (model.sourceType == STModelDataSourceTypePagination) {
self.scrollDirector.paginationControl.paginationState = STPaginationControlStateFailed;
self.tableView.tableFooterView = self.scrollDirector.paginationControl;
}
}
[self.tableView reloadData];
}
- (void)_reloadTableFooterView {
if (self.model.hasNextPage) {
self.scrollDirector.paginationControl.paginationState = STPaginationControlStateNormal;
} else {
self.scrollDirector.paginationControl.paginationState = STPaginationControlStateReachedEnd;
}
self.tableView.tableFooterView = self.scrollDirector.paginationControl;
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
if (self.clearsSelectionOnViewWillAppear) {
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
/// config Cell
return nil;
}
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
return nil;
}
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTextTableViewController.h
================================================
//
// STDTextTableViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-10-12.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDTableViewController.h"
@interface STDTableViewCellItem : STObject
- (instancetype)initWithTitle:(NSString *)title target:(id)target action:(SEL)action;
@property(nonatomic, copy) NSString *title;
//// Cell 点击时的响应事件
@property(nonatomic, weak) id target;
/// action Must have zero argument like someRowClicked {}
@property(nonatomic, assign) SEL action;
@property(nonatomic, strong) id contextInfo;
@property(nonatomic) BOOL switchStyle;
@property(nonatomic) BOOL checked;
@end
@interface STDTableViewSectionItem : STObject
- (instancetype)initWithSectionTitle:(NSString *)title items:(NSArray *)items;
@property(nonatomic, copy) NSString *title;
@property(nonatomic, copy) NSArray *items;
@end
/// 内容都为文本,不做任何定制化的tableView
@interface STDTextTableViewController : STDTableViewController
/// 默认的dataSource, @see STDTableViewSectionItem
@property(nonatomic, copy) NSArray *dataSource;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTextTableViewController.m
================================================
//
// STDTextTableViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-10-12.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDTextTableViewController.h"
@interface STDTextStyleCell : UITableViewCell
@property(nonatomic, strong) UISwitch *switchView;
@property(nonatomic, strong) STDTableViewCellItem *cellItem;
@end
@implementation STDTextStyleCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.switchView = [[UISwitch alloc] init];
self.accessoryView = self.switchView;
[self.switchView addTarget:self action:@selector(_switchActionFired:) forControlEvents:UIControlEventTouchUpInside];
self.textLabel.highlightedTextColor = [UIColor lightGrayColor];
}
return self;
}
- (void)setCellItem:(STDTableViewCellItem *)cellItem {
self.accessoryView = cellItem.switchStyle ? self.switchView : nil;
self.selectionStyle = cellItem.switchStyle ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
self.switchView.on = cellItem.checked;
_cellItem = cellItem;
}
- (void)_switchActionFired:(UISwitch *)uiswitch {
[self.cellItem.target st_performSelector:_cellItem.action withObjects:uiswitch, nil];
self.cellItem.checked = uiswitch.on;
}
@end
@implementation STDTableViewCellItem
- (instancetype)initWithTitle:(NSString *)title target:(id)target action:(SEL)action {
self = [super init];
if (self) {
self.title = title;
self.target = target;
self.action = action;
}
return self;
}
@end
@implementation STDTableViewSectionItem
- (instancetype)initWithSectionTitle:(NSString *)title items:(NSArray *)items {
self = [super init];
if (self) {
self.title = title;
self.items = items;
}
return self;
}
@end
@interface STDTextTableViewController ()
@end
@implementation STDTextTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.scrollDirector.refreshControl.enabled = NO;
self.tableView.backgroundColor = [UIColor st_colorWithRGB:0xF5F5F5];
[self.tableView registerClass:[STDTextStyleCell class] forCellReuseIdentifier:@"Identifier"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
STDTableViewSectionItem *sectionItem = [self.dataSource objectAtIndex:section];
if ([sectionItem isKindOfClass:[STDTableViewSectionItem class]]) {
return sectionItem.title;
}
return nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return self.dataSource.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
STDTableViewSectionItem *sectionItem = [self.dataSource objectAtIndex:section];
if ([sectionItem isKindOfClass:[STDTableViewSectionItem class]]) {
return sectionItem.items.count;
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
STDTextStyleCell *tableViewCell = (STDTextStyleCell *)[tableView dequeueReusableCellWithIdentifier:@"Identifier"];
STDTableViewSectionItem *sectionItem = [self.dataSource objectAtIndex:indexPath.section];
STDTableViewCellItem *item = sectionItem.items[indexPath.row];
if ([item isKindOfClass:[STDTableViewCellItem class]]) {
tableViewCell.textLabel.text = item.title;
if ([tableViewCell isKindOfClass:[STDTextStyleCell class]]) {
tableViewCell.cellItem = item;
}
} else {
tableViewCell.textLabel.text = @"配置出现问题";
}
return tableViewCell;
}
- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
if (![view isKindOfClass:[UITableViewHeaderFooterView class]]) {
return;
}
UILabel *textLabel = ((UITableViewHeaderFooterView *)view).textLabel;
STDTableViewSectionItem *sectionItem = [self.dataSource objectAtIndex:section];
if ([sectionItem isKindOfClass:[STDTableViewSectionItem class]]) {
textLabel.text = sectionItem.title;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
STDTableViewSectionItem *sectionItem = [self.dataSource objectAtIndex:indexPath.section];
STDTableViewCellItem *item = sectionItem.items[indexPath.row];
if ([item isKindOfClass:[STDTableViewCellItem class]] && [item.target respondsToSelector:item.action]) {
[item.target st_performSelector:item.action withObjects:nil, nil];
}
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTransitionDelegate.h
================================================
//
// STDTransitionDelegate.h
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
@interface STDTransitionDelegate : NSObject <STNavigationControllerDelegate>
+ (instancetype)sharedDelegate;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDTransitionDelegate.m
================================================
//
// STDTransitionDelegate.m
// STKitDemo
//
// Created by SunJiangting on 15-4-3.
// Copyright (c) 2015年 SunJiangting. All rights reserved.
//
#import "STDTransitionDelegate.h"
@implementation STDTransitionDelegate
static id _sharedDelegate;
+ (instancetype)sharedDelegate {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedDelegate = [[self alloc] init];
});
return _sharedDelegate;
}
- (BOOL)navigationController:(STNavigationController *)navigationController
shouldBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
return NO;
}
- (void)navigationController:(STNavigationController *)navigationController
willBeginTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
}
- (void)navigationController:(STNavigationController *)navigationController
transitingWithContext:(STNavigationControllerTransitionContext *)transitionContext {
}
- (void)navigationController:(STNavigationController *)navigationController
didEndTransitionContext:(STNavigationControllerTransitionContext *)transitionContext {
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDViewController.h
================================================
//
// STDViewController.h
// STKitDemo
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <STKit/STKit.h>
@interface STDViewController : STViewController
@property (nonatomic, assign) BOOL customizeEdgeOffset;
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDViewController.m
================================================
//
// STDViewController.m
// STKitDemo
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
@interface STDViewController () <UIGestureRecognizerDelegate>
@property(nonatomic, strong) UIView *presentationView;
@end
@implementation STDViewController
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.customizeEdgeOffset = YES;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor st_colorWithRGB:0xF9F9F9];
self.presentationView = [[UIView alloc] initWithFrame:self.view.bounds];
self.presentationView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// [self.view addSubview:self.presentationView];
UIPanGestureRecognizer *panGestureRecognizer =
[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureRecognizerActionFired:)];
[self.presentationView addGestureRecognizer:panGestureRecognizer];
__weak STDViewController *weakSelf = self;
self.presentationView.hitTestBlock = ^(CGPoint point, UIEvent *event, BOOL *returnSuper) {
if (ABS(CGRectGetWidth(weakSelf.view.frame) - point.x) < 20) {
*returnSuper = YES;
return (UIView *)nil;
}
return (UIView *)nil;
};
if (STGetSystemVersion() < 7) {
self.st_navigationBar.backgroundImage = [UIImage imageNamed:@"header_bkg"];
}
CGFloat value = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultEdgeOffset"] floatValue];
if (value == 0) {
value = 80;
[[STPersistence standardPersistence] setValue:@(value) forKey:@"STDNavigationDefaultEdgeOffset"];
}
if (self.customizeEdgeOffset) {
self.st_maximumInteractivePopEdgeDistance = value;
}
CGFloat value1 = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultOffset"] floatValue];
if (value1 == 0) {
value1 = 80;
[[STPersistence standardPersistence] setValue:@(value1) forKey:@"STDNavigationDefaultOffset"];
}
self.st_interactivePopTransitionOffset = value1;
// Do any additional setup after loading the view, typically from a nib.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(maximumInteractiveDistanceChanged:)
name:@"STDNavigationDefaultEdgeOffset"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(maximumInteractiveOffsetChanged:)
name:@"STDNavigationDefaultOffset"
object:nil];
}
- (void)maximumInteractiveDistanceChanged:(id)sender {
self.st_maximumInteractivePopEdgeDistance = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultEdgeOffset"] floatValue];
}
- (void)maximumInteractiveOffsetChanged:(id)sender {
if (self.customizeEdgeOffset) {
self.st_interactivePopTransitionOffset = [[[STPersistence standardPersistence] valueForKey:@"STDNavigationDefaultOffset"] floatValue];
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)panGestureRecognizerActionFired:(UIPanGestureRecognizer *)sender {
switch (sender.state) {
case UIGestureRecognizerStateBegan:
[self panGestureDidBegan:sender];
break;
case UIGestureRecognizerStateChanged:
[self panGestureDidChanged:sender];
break;
case UIGestureRecognizerStateCancelled:
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateFailed:
[self panGestureDidCancelled:sender];
break;
default:
break;
}
}
static UIView *_statusBarSuperview;
- (void)panGestureDidBegan:(UIPanGestureRecognizer *)sender {
// _statusBarSuperview = self.view.statusBarWindow.superview;
// [self.view.statusBarWindow removeFromSuperview];
// [self.view addSubview:self.view.statusBarWindow];
// self.view.layer.masksToBounds = NO;
// self.view.clipsToBounds = NO;
}
- (void)panGestureDidChanged:(UIPanGestureRecognizer *)sender {
CGPoint translation = [sender translationInView:self.view];
if (ABS(translation.x) < 160) {
CGFloat maximumAngel = M_PI_2;
CATransform3D transform = CATransform3DMakeRotation(maximumAngel * (ABS(translation.x) / 240.0), 0., 1.0, 0.0);
self.view.layer.transform = transform;
CGFloat percent = ABS(translation.x) / 160.0f;
[self transformView:self.view offset:-5 percent:percent];
}
}
- (void)transformView:(UIView *)view offset:(CGFloat)offset percent:(CGFloat)percent {
[view.subviews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
[self transformView:obj offset:(offset - 5)percent:percent];
CATransform3D transform1 = CATransform3DMakeTranslation(offset * 0.2 * percent, -offset * percent, 0);
// transform = CATransform3DRotate(transform, 85 * M_PI / 180, .0, 1.0, 0);
CATransform3D transform2 = CATransform3DMakeRotation(M_PI * 0.2 * percent, 0.5, 1.0, .0);
CATransform3D transform = CATransform3DConcat(transform1, transform2);
transform.m34 = -1.0 / 250.0;
obj.layer.transform = transform;
}];
}
- (void)resetView:(UIView *)view {
[view.subviews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) {
[self resetView:obj];
obj.layer.transform = CATransform3DIdentity;
}];
}
- (void)panGestureDidCancelled:(UIPanGestureRecognizer *)sender {
[self resetView:self.view];
self.view.layer.transform = CATransform3DIdentity;
// [self.view.statusBarWindow removeFromSuperview];
// [_statusBarSuperview addSubview:self.view.statusBarWindow];
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDropMenuView.h
================================================
//
// STDropMenuView.h
// STKitDemo
//
// Created by SunJiangting on 14-8-14.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
@interface STDropMenuView : STPopoverView
- (instancetype) initWithMenuTitles:(NSString *) menuTitle, ... NS_REQUIRES_NIL_TERMINATION;
@property (nonatomic, strong) void (^ dismissHandler) (STDropMenuView * dropView, NSInteger index);
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STDropMenuView.m
================================================
//
// STDropMenuView.m
// STKitDemo
//
// Created by SunJiangting on 14-8-14.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDropMenuView.h"
@interface _STDropMenuCell : UITableViewCell
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UIView *separatorView;
@end
const CGFloat _STDropMenuCellHeight = 45;
@implementation _STDropMenuCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.frame = CGRectMake(0, 0, 320, _STDropMenuCellHeight);
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 300, 44)];
self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.titleLabel.textColor = [UIColor darkGrayColor];
self.titleLabel.highlightedTextColor = [UIColor whiteColor];
self.titleLabel.font = [UIFont systemFontOfSize:17.];
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLabel];
self.separatorView = [[UIView alloc] initWithFrame:CGRectZero];
[self addSubview:self.separatorView];
}
return self;
}
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
self.separatorView.frame = CGRectMake(0, CGRectGetHeight(frame) - STOnePixel(), CGRectGetWidth(frame), STOnePixel());
}
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
self.separatorView.backgroundColor = [UIColor st_colorWithRGB:0x999999];
}
@end
@interface STDropMenuView () <UITableViewDataSource, UITableViewDelegate>
@property(nonatomic, strong) NSMutableArray *dataSource;
@property(nonatomic, strong) UITableView *tableView;
@end
@implementation STDropMenuView
- (instancetype)initWithMenuTitles:(NSString *)menuTitle, ... NS_REQUIRES_NIL_TERMINATION {
NSMutableArray *dataSource = [NSMutableArray arrayWithCapacity:1];
NSString *title = nil;
va_list args;
if (menuTitle) {
[dataSource addObject:menuTitle];
va_start(args, menuTitle);
while ((title = va_arg(args, NSString *))) {
[dataSource addObject:title];
}
va_end(args);
}
self = [super initWithFrame:CGRectZero];
if (self) {
self.dataSource = dataSource;
self.contentOffset = CGPointMake(0, 64);
self.direction = STPopoverViewDirectionDown;
CGFloat maxHeight = 240;
const CGFloat footerHeight = 1;
CGFloat height = dataSource.count * _STDropMenuCellHeight + footerHeight;
STTableView *tableView = [[STTableView alloc]
initWithFrame:CGRectMake(0, STOnePixel(), CGRectGetWidth([UIScreen mainScreen].applicationFrame), MIN(height, maxHeight))
style:UITableViewStylePlain];
tableView.scrollsToTop = NO;
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundView = nil;
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.userInteractionEnabled = YES;
[tableView registerClass:[_STDropMenuCell class] forCellReuseIdentifier:@"Identifier"];
[self.contentView addSubview:tableView];
self.tableView = tableView;
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, footerHeight)];
tableView.tableFooterView.backgroundColor = [UIColor st_colorWithRGB:0xFF7300];
if (height > maxHeight) {
tableView.scrollEnabled = YES;
} else {
tableView.scrollEnabled = NO;
}
}
return self;
}
- (void)showInView:(UIView *)view animated:(BOOL)animated {
[super showInView:view animated:YES];
self.tableView.contentInset = UIEdgeInsetsZero;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return _STDropMenuCellHeight;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
_STDropMenuCell *tableViewCell = [tableView dequeueReusableCellWithIdentifier:@"Identifier"];
tableViewCell.titleLabel.text = self.dataSource[indexPath.row];
return tableViewCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self dismissAnimated:YES];
if (self.dismissHandler) {
self.dismissHandler(self, indexPath.row);
}
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/STMenuView.h
================================================
//
// STMenuView.h
// STKitDemo
//
// Created by SunJiangting on 14-3-24.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface STMenuItem : NSObject
@property(nonatomic, strong) UIImage *image;
@property(nonatomic, strong) UIImage *highlightedImage;
@property(nonatomic, strong) NSString *title;
- (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage title:(NSString *)title;
@end
@class STMenuView;
typedef void (^STMenuDismissHandler)(STMenuView *menuView, int dismissIndex);
@interface STMenuView : UIView
@property(nonatomic, strong) STMenuDismissHandler dismissHandler;
/// default initializer
- (instancetype)initWithDelegate:(id<NSObject>)delegate menuItem:(STMenuItem *)menuItem, ... NS_REQUIRES_NIL_TERMINATION;
- (instancetype)initWithDelegate:(id<NSObject>)delegate menuItems:(NSArray *)menuItems;
/// if view==nil, view = keyWindow
- (void)showInView:(UIView *)view animated:(BOOL)animated;
- (void)dismissAnimated:(BOOL)animated;
- (STMenuItem *)menuItemAtIndex:(NSUInteger)index;
@end
extern const CGSize STMenuItemImageSize;
================================================
FILE: STKitDemo/Classes/BaseUI/STMenuView.m
================================================
//
// STMenuView.m
// STKitDemo
//
// Created by SunJiangting on 14-3-24.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STMenuView.h"
#import <STKit/UIKit+STKit.h>
#import <STKit/STButton.h>
@implementation STMenuItem : NSObject
- (instancetype)initWithImage:(UIImage *)image highlightedImage:(UIImage *)highlightedImage title:(NSString *)title {
self = [super init];
if (self) {
self.title = title;
self.image = image;
self.highlightedImage = highlightedImage;
}
return self;
}
@end
@interface STMenuView () <UIGestureRecognizerDelegate>
@property(nonatomic, strong) UIImageView *blurView;
@property(nonatomic, strong) NSMutableArray *dataSource;
@property(nonatomic, strong) UIButton *dismissButton;
@property(nonatomic, strong) NSMutableArray *menuItemViews;
@end
@implementation STMenuView
- (void)dealloc {
// [self.hitTestButton removeObserver:self forKeyPath:@"highlighted"];
}
- (instancetype)initWithDelegate:(id<NSObject>)delegate menuItem:(STMenuItem *)menuItem0, ... {
NSMutableArray *menuItems = [NSMutableArray arrayWithCapacity:1];
STMenuItem *menuItem = nil;
va_list args;
if (menuItem0) {
[menuItems addObject:menuItem0];
va_start(args, menuItem0);
while ((menuItem = va_arg(args, STMenuItem *))) {
[menuItems addObject:menuItem];
}
va_end(args);
}
return [self initWithDelegate:delegate menuItems:menuItems];
}
- (instancetype)initWithDelegate:(id<NSObject>)delegate menuItems:(NSArray *)menuItems {
self = [super initWithFrame:CGRectZero];
if (self) {
self.dataSource = [NSMutableArray arrayWithArray:menuItems];
self.menuItemViews = [NSMutableArray arrayWithCapacity:menuItems.count];
self.blurView = [[UIImageView alloc] initWithFrame:self.bounds];
self.blurView.userInteractionEnabled = YES;
self.blurView.backgroundColor = [UIColor clearColor];
self.blurView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.blurView.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:self.blurView];
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panGestureActionFired:)];
panGestureRecognizer.delegate = self;
[self.blurView addGestureRecognizer:panGestureRecognizer];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureActionFired:)];
tapGestureRecognizer.delegate = self;
[self.blurView addGestureRecognizer:tapGestureRecognizer];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"取消" forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"aero_button"] forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(dismissAnimated:) forControlEvents:UIControlEventTouchUpInside];
[self.blurView addSubview:button];
[self reloadMenuItems];
self.dismissButton = button;
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(20, 20, 280, 40)];
slider.minimumValue = 50;
slider.maximumValue = 100;
slider.value = 100;
[slider addTarget:self action:@selector(sliderValueActionFired:) forControlEvents:UIControlEventValueChanged];
[self.blurView addSubview:slider];
}
return self;
}
- (void)sliderValueActionFired:(UISlider *)slider {
self.blurView.alpha = slider.value / 100;
}
- (STMenuItem *)menuItemAtIndex:(NSUInteger)index {
return [self.dataSource objectAtIndex:index];
}
- (void)reloadMenuItems {
[self.menuItemViews enumerateObjectsUsingBlock:^(UIView *view, NSUInteger idx, BOOL *stop) { [view removeFromSuperview]; }];
[self.menuItemViews removeAllObjects];
[self.dataSource enumerateObjectsUsingBlock:^(STMenuItem *menuItem, NSUInteger idx, BOOL *stop) {
STButton *button = [STButton buttonWithType:UIButtonTypeCustom];
button.usingSystemLayout = NO;
button.imageView.image = menuItem.image;
button.titleLabel.text = menuItem.title;
[self.blurView addSubview:button];
[self.menuItemViews addObject:button];
}];
}
- (void)showInView:(UIView *)view animated:(BOOL)animated {
if (!view) {
view = [UIApplication sharedApplication].keyWindow;
}
UIImage *snapView = [view st_snapshotImage];
UIImage *image = [snapView st_blurImageWithStyle:STBlurEffectStyleLight];
self.blurView.image = image;
self.frame = view.bounds;
[view addSubview:self];
self.dismissButton.frame = CGRectMake(0, CGRectGetHeight(view.frame) - 49, CGRectGetWidth(view.frame), 49);
[self layoutMenuItems];
self.blurView.alpha = 0;
void (^animation)(void) = ^{ self.blurView.alpha = 1.0; };
void (^completion)(BOOL) = ^(BOOL finished) { self.blurView.alpha = 1.0; };
[self riseAnimation];
if (animated) {
[UIView animateWithDuration:0.35 animations:animation completion:completion];
} else {
animation();
completion(YES);
}
}
- (CGRect)frameForMenuAtIndex:(NSUInteger)index {
NSUInteger columnCount = 3;
NSUInteger columnIndex = index % columnCount;
NSUInteger rowCount = self.menuItemViews.count / columnCount + (self.menuItemViews.count % columnCount > 0 ? 1 : 0);
NSUInteger rowIndex = index / columnCount;
CGFloat itemHeight = (STMenuItemImageSize.height + 20) * rowCount + (rowCount > 1 ? (rowCount - 1) * 10 : 0);
CGFloat offsetY = (CGRectGetHeight(self.bounds) - itemHeight - CGRectGetHeight(self.dismissButton.bounds)) / 2.0;
CGFloat verticalPadding = (CGRectGetWidth(self.bounds) - 10 * 2 - STMenuItemImageSize.height * 3) / 2.0;
CGFloat offsetX = 10;
offsetX += (STMenuItemImageSize.height + verticalPadding) * columnIndex;
offsetY += (STMenuItemImageSize.height + 30) * rowIndex;
return CGRectMake(offsetX, offsetY, STMenuItemImageSize.width, STMenuItemImageSize.width + 20);
}
- (void)layoutMenuItems {
[self.menuItemViews enumerateObjectsUsingBlock:^(STButton *subview, NSUInteger idx, BOOL *stop) {
subview.frame = [self frameForMenuAtIndex:idx];
subview.imageView.frame = CGRectMake(0, 0, STMenuItemImageSize.width, STMenuItemImageSize.height);
subview.titleLabel.frame = CGRectMake(0, STMenuItemImageSize.height, STMenuItemImageSize.width, 20);
}];
}
- (void)dismissAnimated:(BOOL)animated {
[self dropAnimation];
self.blurView.alpha = 1.0;
void (^animation)(void) = ^{ self.blurView.alpha = 0.0; };
void (^completion)(BOOL) = ^(BOOL finished) {
self.blurView.alpha = 0.0;
self.blurView.image = nil;
[self.menuItemViews enumerateObjectsUsingBlock:^(UIView *obj, NSUInteger idx, BOOL *stop) { [obj.layer removeAllAnimations]; }];
[self removeFromSuperview];
};
if (animated) {
[UIView animateWithDuration:0.35 animations:animation completion:completion];
} else {
animation();
completion(YES);
}
[[NSURLCache sharedURLCache] setMemoryCapacity:1024];
}
- (void)hitButtonTouchUpInside:(UIButton *)sender {
[self.dismissButton sendActionsForControlEvents:UIControlEventTouchUpInside];
}
- (void)riseAnimation {
NSUInteger columnCount = 3;
NSUInteger rowCount = self.menuItemViews.count / columnCount + (self.menuItemViews.count % columnCount > 0 ? 1 : 0);
[self.menuItemViews enumerateObjectsUsingBlock:^(STButton *button, NSUInteger idx, BOOL *stop) {
button.layer.opacity = 0;
CGRect frame = [self frameForMenuAtIndex:idx];
NSInteger rowIndex = idx / columnCount;
NSInteger columnIndex = idx % columnCount;
CGPoint fromPosition = CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2.0,
frame.origin.y + (rowCount - rowIndex + 2) * 200 + (STMenuItemImageSize.height + 20) / 2);
CGPoint toPosition = CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2, frame.origin.y + (STMenuItemImageSize.height + 20) / 2.);
double delayInSeconds = rowIndex * columnCount * 0.07;
if (!columnIndex) {
delayInSeconds += 0.07;
} else if (columnIndex == 2) {
delayInSeconds += 0.07 * 2;
}
CABasicAnimation *positionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
positionAnimation.fromValue = [NSValue valueWithCGPoint:fromPosition];
positionAnimation.toValue = [NSValue valueWithCGPoint:toPosition];
positionAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.45f:0.6f:0.75f:1.0f];
positionAnimation.duration = 0.35;
positionAnimation.beginTime = [button.layer convertTime:CACurrentMediaTime() fromLayer:nil] + delayInSeconds;
[positionAnimation setValue:[NSNumber numberWithUnsignedInteger:idx] forKey:@"STMenuPresentAnimationKey"];
positionAnimation.delegate = self;
[button.layer addAnimation:positionAnimation forKey:@"riseAnimation"];
}];
}
- (void)dropAnimation {
NSUInteger columnCount = 3;
__block double delayInSeconds;
[self.menuItemViews enumerateObjectsUsingBlock:^(UIView *button, NSUInteger idx, BOOL *stop) {
button.layer.opacity = 1.0;
CGRect frame = [self frameForMenuAtIndex:idx];
NSInteger rowIndex = idx / columnCount;
NSInteger columnIndex = idx % columnCount;
CGPoint fromPosition =
CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2.0, frame.origin.y + (STMenuItemImageSize.height + 20) / 2.0);
CGPoint toPosition = CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2.0,
frame.origin.y - (rowIndex + 2) * 200 + (STMenuItemImageSize.height + 20) / 2.0);
delayInSeconds = rowIndex * columnCount * 0.07;
if (!columnIndex) {
delayInSeconds += 0.07;
} else if (columnIndex == 2) {
delayInSeconds += 0.07 * 2;
}
CABasicAnimation *positionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
positionAnimation.fromValue = [NSValue valueWithCGPoint:fromPosition];
positionAnimation.toValue = [NSValue valueWithCGPoint:toPosition];
positionAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.3:0.5f:1.0f:1.0f];
positionAnimation.duration = 0.35;
positionAnimation.beginTime = [button.layer convertTime:CACurrentMediaTime() fromLayer:nil] + delayInSeconds;
[positionAnimation setValue:[NSNumber numberWithUnsignedInteger:idx] forKey:@"STMenuDismissAnimationKey"];
positionAnimation.delegate = self;
[button.layer addAnimation:positionAnimation forKey:@"riseAnimation"];
}];
}
- (void)animationDidStart:(CAAnimation *)animation {
NSUInteger columnCount = 3;
if ([animation valueForKey:@"STMenuPresentAnimationKey"]) {
NSUInteger index = [[animation valueForKey:@"STMenuPresentAnimationKey"] unsignedIntegerValue];
UIView *view = self.menuItemViews[index];
CGRect frame = [self frameForMenuAtIndex:index];
CGPoint toPosition = CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2.0, frame.origin.y + (STMenuItemImageSize.height + 20) / 2.0);
CGFloat toAlpha = 1.0;
view.layer.position = toPosition;
view.layer.opacity = toAlpha;
} else if ([animation valueForKey:@"STMenuDismissAnimationKey"]) {
NSUInteger index = [[animation valueForKey:@"STMenuDismissAnimationKey"] unsignedIntegerValue];
NSUInteger rowIndex = index / columnCount;
UIView *view = self.menuItemViews[index];
CGRect frame = [self frameForMenuAtIndex:index];
CGPoint toPosition = CGPointMake(frame.origin.x + STMenuItemImageSize.width / 2.0,
frame.origin.y - (rowIndex + 2) * 200 + (STMenuItemImageSize.height + 20) / 2.0);
view.layer.position = toPosition;
}
}
- (void)panGestureActionFired:(UIPanGestureRecognizer *)sender {
static BOOL effected = NO;
switch (sender.state) {
case UIGestureRecognizerStateBegan:
effected = YES;
self.dismissButton.highlighted = YES;
break;
case UIGestureRecognizerStateChanged:
if (ABS([sender translationInView:self.blurView].x) > 50 || ABS([sender translationInView:self.blurView].y) > 50) {
effected = NO;
self.dismissButton.highlighted = NO;
} else {
self.dismissButton.highlighted = YES;
effected = YES;
}
break;
case UIGestureRecognizerStateFailed:
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateCancelled:
if (effected) {
[self.dismissButton sendActionsForControlEvents:UIControlEventTouchUpInside];
}
self.dismissButton.highlighted = NO;
break;
default:
break;
}
}
- (void)tapGestureActionFired:(UITapGestureRecognizer *)sender {
switch (sender.state) {
case UIGestureRecognizerStateBegan:
self.dismissButton.highlighted = YES;
break;
case UIGestureRecognizerStateChanged:
break;
case UIGestureRecognizerStateFailed:
case UIGestureRecognizerStateEnded:
case UIGestureRecognizerStateCancelled:
[self.dismissButton sendActionsForControlEvents:UIControlEventTouchUpInside];
self.dismissButton.highlighted = NO;
break;
default:
break;
}
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if (touch.view == self.blurView) {
self.dismissButton.highlighted = YES;
return YES;
}
return NO;
}
@end
const CGSize STMenuItemImageSize = {75, 75};
================================================
FILE: STKitDemo/Classes/BaseUI/SideBar/STDLeftViewController.h
================================================
//
// STDLeftViewController.h
// STKitDemo
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
@interface STDLeftViewController : STDViewController
@end
================================================
FILE: STKitDemo/Classes/BaseUI/SideBar/STDLeftViewController.m
================================================
//
// STDLeftViewController.m
// STKitDemo
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import "STDLeftViewController.h"
#import "STDAboutViewController.h"
@interface STDLeftViewController () <UITableViewDataSource, UITableViewDelegate, STLinkLabelDelegate>
@property(nonatomic, weak) UITableView *tableView;
@property(nonatomic, strong) NSArray *dataSource;
@end
@implementation STDLeftViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.dataSource = @[
@{ @"title" : @"地图",
@"image" : @"SideBarNearby" },
@{ @"title" : @"组件",
@"image" : @"tab_receipt" },
@{ @"title" : @"服务",
@"image" : @"tab_service" },
@{ @"title" : @"我的",
@"image" : @"tab_profile" }
];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
CGRect rect = self.view.bounds;
UIImageView *headerView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, 87)];
headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
headerView.image = [UIImage imageNamed:@"left_account_header.png"];
headerView.contentMode = UIViewContentModeLeft;
[self.view addSubview:headerView];
rect.origin.y += 37;
rect.size.height -= 77;
UITableView *tableView = [[UITableView alloc] initWithFrame:rect style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Identifier"];
tableView.dataSource = self;
tableView.delegate = self;
tableView.scrollsToTop = NO;
[self.view addSubview:tableView];
self.tableView = tableView;
STLinkLabel *linkLabel = [[STLinkLabel alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(rect) + 10, CGRectGetWidth(rect) - 40, 30)];
linkLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
linkLabel.backgroundColor = [UIColor clearColor];
linkLabel.delegate = self;
linkLabel.font = [UIFont systemFontOfSize:15];
// NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
linkLabel.text = @"<link href=\"stkit://current/about\">关于STKit</link> Copyright 2014";
[self.view addSubview:linkLabel];
UIView *tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 280, 49.5)];
nameLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
nameLabel.font = [UIFont boldSystemFontOfSize:18.];
nameLabel.textColor = [UIColor blackColor];
nameLabel.backgroundColor = [UIColor clearColor];
nameLabel.text = @"STKitDemo";
[tableHeaderView addSubview:nameLabel];
UIView *separatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 49.5, CGRectGetWidth(tableView.frame), 0.5)];
separatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
separatorView.backgroundColor = [UIColor lightGrayColor];
[tableHeaderView addSubview:separatorView];
tableView.tableHeaderView = tableHeaderView;
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 1)];
[tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionBottom];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.dataSource.count;
}
// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with
// dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Identifier"];
NSDictionary *information = [self.dataSource objectAtIndex:indexPath.row];
NSString *title = [information valueForKey:@"title"];
NSString *imageName = [information valueForKey:@"image"];
cell.textLabel.text = title;
cell.textLabel.textColor = [UIColor st_colorWithRGB:0xACACAC];
cell.textLabel.highlightedTextColor = [UIColor st_colorWithRGB:0xFF7300];
cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_normal.png", imageName]];
cell.imageView.highlightedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted.png", imageName]];
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 40.;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.st_sideBarController.selectedIndex = indexPath.row;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
#pragma mark - STLinkLabelDelegate
- (void)linkLabel:(STLinkLabel *)linkLabel didSelectLinkObject:(STLinkObject *)linkObject {
if ([linkObject.URL.absoluteString hasSuffix:@"about"]) {
STDAboutViewController *aboutViewController = [[STDAboutViewController alloc] init];
aboutViewController.hidesBottomBarWhenPushed = YES;
[self.st_sideBarController.st_navigationController pushViewController:aboutViewController animated:YES];
}
}
@end
================================================
FILE: STKitDemo/Classes/BaseUI/SideBar/STDSideBarController.h
================================================
//
// STDSideBarController.h
// STKit
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import <STKit/STSideBarController.h>
@interface STDSideBarController : STSideBarController
@end
================================================
FILE: STKitDemo/Classes/BaseUI/SideBar/STDSideBarController.m
================================================
//
// STDSideBarController.m
// STKitDemo
//
// Created by SunJiangting on 13-11-20.
// Copyright (c) 2013年 SunJiangting. All rights reserved.
//
#import "STDSideBarController.h"
#import "STARootViewController.h"
#import "STDMoreViewController.h"
#import "STDMapViewController.h"
#import "STDemoViewController.h"
#import "STDServiceViewController.h"
@interface STDSideBarController ()
@end
@implementation STDSideBarController
- (instancetype)initWithRootViewController:(UIViewController *)rootViewController {
self = [super initWithRootViewController:rootViewController];
if (self) {
STDMapViewController *mapViewController = STDMapViewController.new;
STNavigationController *mapNavigationController = [[STNavigationController alloc] initWithRootViewController:mapViewController];
STDemoViewController *controlsViewController = [[STDemoViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *controlsNavigationController = [[STNavigationController alloc] initWithRootViewController:controlsViewController];
STDServiceViewController *serviceViewController = [[STDServiceViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *serviceNavigationController = [[STNavigationController alloc] initWithRootViewController:serviceViewController];
STDMoreViewController *moreViewController = [[STDMoreViewController alloc] initWithStyle:UITableViewStyleGrouped];
STNavigationController *moreNavigationController = [[STNavigationController alloc] initWithRootViewController:moreViewController];
self.viewControllers = @[mapNavigationController, controlsNavigationController, serviceNavigationController, moreNavigationController];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDCardViewController.h
================================================
//
// STDCardViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDFeedViewController.h"
/// 明星片
@interface STDCardViewController : STDFeedViewController
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDCardViewController.m
================================================
//
// STDCardViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDCardViewController.h"
@interface STDCardViewController ()
@property (nonatomic, strong) STHTTPNetwork *network;
@end
@implementation STDCardViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.network = [[STHTTPNetwork alloc] init];
}
return self;
}
- (void) viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"明信片";
}
- (void) loadDataWithPage:(NSInteger)page size:(NSInteger)size completionHandler:(STDFeedLoadHandler)completionHandler {
NSDictionary * parameters = @{@"page":@(page), @"size":@(size)};
NSString *URLString = @"http://www.lovecard.sinaapp.com/open/photo/list/";
STHTTPOperation *operation = [STHTTPOperation operationWithURLString:URLString parameters:parameters];
[self.network sendHTTPOperation:operation completionHandler:^(STHTTPOperation *operation, id response, NSError *error) {
if (!error) {
NSMutableArray * result = [NSMutableArray arrayWithCapacity:2];
NSArray * array = [response objectForKey:@"photos"];
BOOL hasMore = [[response objectForKey:@"more"] boolValue] && array.count > 0;
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
STDFeedItem * feedItem = [[STDFeedItem alloc] initWithDictionary:obj];
[result addObject:feedItem];
}];
if (completionHandler) {
completionHandler([result copy], hasMore, nil);
}
} else {
if (completionHandler) {
completionHandler(nil, NO, error);
}
}
}];
}
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedCell.h
================================================
//
// STDFeedCell.h
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "STDFeedItem.h"
@interface STDFeedCell : UICollectionViewCell
@property (nonatomic, strong) UIImageView * imageView;
@property (nonatomic, strong) STLabel * titleLabel;
@property (nonatomic, strong) STDFeedItem * feedItem;
- (void) reloadUI;
+ (CGFloat) heightForCollectionCellWithFeedItem:(STDFeedItem *) feedItem constrainedToWidth:(CGFloat) width;
@end
extern UIEdgeInsets const STDFeedCellContentInset;
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedCell.m
================================================
//
// STDFeedCell.m
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDFeedCell.h"
#import "STDFeedImageView.h"
@interface STDFeedHotView : UIView
@property (nonatomic, strong) UIImageView * imageView;
@property (nonatomic, strong) UILabel * textLabel;
@end
@implementation STDFeedHotView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 14, 20)];
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.image = [UIImage imageNamed:@"feed_hot_icon"];
[self addSubview:self.imageView];
self.textLabel = [[UILabel alloc] initWithFrame:CGRectMake(18, 4, 30, 16)];
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.textColor = [UIColor st_colorWithRGB: 0xFF7300];
self.textLabel.font = [UIFont systemFontOfSize:14.];
self.textLabel.text = @"Hot";
[self addSubview:self.textLabel];
}
return self;
}
@end
const CGSize STDFeedCellDefaultSize = {50, 70};
const CGFloat STDFeedCellAccessoryHeight = 30;
const UIEdgeInsets STDFeedCellTitleContentInset = {5,5,10,5};
@interface STDFeedCell ()
@property (nonatomic, strong) UIImageView * backgroundImageView;
@property (nonatomic, strong) UIView * containerView;
@property (nonatomic, strong) UIView * accessoryView;
@property (nonatomic, strong) STDFeedHotView * hotView;
@end
@implementation STDFeedCell
- (instancetype) initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.frame = CGRectMake(0, 0, STDFeedCellDefaultSize.width, STDFeedCellDefaultSize.height);
self.contentView.frame = self.bounds;
self.backgroundColor = [UIColor st_colorWithRGB:0xCCCCCC];
self.backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(STDFeedCellContentInset.left, STDFeedCellContentInset.top, STDFeedCellDefaultSize.width - (STDFeedCellContentInset.left + STDFeedCellContentInset.right), STDFeedCellDefaultSize.height - (STDFeedCellContentInset.top + STDFeedCellContentInset.bottom))];
self.backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.backgroundImageView.image = [[UIImage imageNamed:@"feed_cell_background"] resizableImageWithCapInsets:UIEdgeInsetsMake(20, 70, 20, 70) resizingMode:UIImageResizingModeStretch];
self.backgroundImageView.userInteractionEnabled = YES;
[self.contentView addSubview:self.backgroundImageView];
self.imageView = [[STDFeedImageView alloc] initWithFrame:CGRectZero];
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
self.imageView.clipsToBounds = YES;
self.imageView.userInteractionEnabled = YES;
self.imageView.st_placeholderImage = [UIImage imageNamed:@"product_default"];
[self.backgroundImageView addSubview:self.imageView];
self.containerView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, 40, 40)];
self.containerView.backgroundColor = [UIColor clearColor];
[self.backgroundImageView addSubview:self.containerView];
self.titleLabel = [[STLabel alloc] initWithFrame:CGRectZero];
self.titleLabel.verticalAlignment = STVerticalAlignmentTop;
self.titleLabel.backgroundColor = [UIColor clearColor];
self.titleLabel.font = [UIFont systemFontOfSize:14];
self.titleLabel.textColor = [UIColor darkGrayColor];
self.titleLabel.numberOfLines = 0;
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[self.containerView addSubview:self.titleLabel];
self.accessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, STDFeedCellAccessoryHeight)];
self.accessoryView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
[self.containerView addSubview:self.accessoryView];
UIView * separatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, STOnePixel())];
separatorView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
separatorView.backgroundColor = [UIColor st_colorWithRGB:0xdddddd];
[self.accessoryView addSubview:separatorView];
self.hotView = [[STDFeedHotView alloc] initWithFrame:CGRectMake(5, 2, 60, STDFeedCellAccessoryHeight)];
[self.accessoryView addSubview:self.hotView];
UIImageView * coverView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 60)];
coverView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
coverView.image = [[UIImage imageNamed:@"feed_cell_border"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 15, 15, 15) resizingMode:UIImageResizingModeStretch];
coverView.userInteractionEnabled = NO;
[self.backgroundImageView addSubview:coverView];
}
return self;
}
- (void) setFeedItem:(STDFeedItem *)feedItem {
if (_feedItem != feedItem) {
[self.imageView st_setImageWithURLString:feedItem.thumbURLString];
self.titleLabel.text = feedItem.title;
_feedItem = feedItem;
}
[self reloadUI];
}
- (void) reloadUI {
CGFloat width = CGRectGetWidth(self.frame) - STDFeedCellContentInset.left - STDFeedCellContentInset.right;
CGFloat imageHeight = self.feedItem.height * width / self.feedItem.width;
self.imageView.frame = CGRectMake(0, 0, width, imageHeight);
self.containerView.frame = CGRectMake(0, CGRectGetMaxY(self.imageView.frame), width, CGRectGetHeight(self.frame) - CGRectGetMaxY(self.imageView.frame));
if (self.feedItem.title.length > 0) {
self.titleLabel.frame = CGRectMake(STDFeedCellTitleContentInset.left, STDFeedCellTitleContentInset.top, CGRectGetWidth(self.containerView.frame) - STDFeedCellTitleContentInset.left - STDFeedCellTitleContentInset.right, CGRectGetHeight(self.containerView.frame) - STDFeedCellAccessoryHeight - STDFeedCellTitleContentInset.top - STDFeedCellTitleContentInset.bottom);
}
}
+ (CGFloat) heightForCollectionCellWithFeedItem:(STDFeedItem *) feedItem constrainedToWidth:(CGFloat) _width {
if (feedItem.width * feedItem.height == 0) {
return 0;
}
CGFloat width = _width - STDFeedCellContentInset.left - STDFeedCellContentInset.right;
CGFloat height = feedItem.height * width / feedItem.width + STDFeedCellContentInset.top + STDFeedCellContentInset.bottom;
if (feedItem.title.length > 0) {
CGFloat titleWidth = width - (STDFeedCellTitleContentInset.left + STDFeedCellTitleContentInset.right);
CGFloat titleHeight = [feedItem.title st_heightWithFont:[UIFont systemFontOfSize:14] constrainedToWidth:titleWidth];
height += (titleHeight + STDFeedCellTitleContentInset.top + STDFeedCellTitleContentInset.bottom);
}
height += STDFeedCellAccessoryHeight;
return height;
}
@end
UIEdgeInsets const STDFeedCellContentInset = {5, 5, 5, 5};
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedImageView.h
================================================
//
// STDFeedImageView.h
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface STDFeedImageView : UIImageView
@property (nonatomic, strong, readonly) UIView * selectedView;
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedImageView.m
================================================
//
// STDFeedImageView.m
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDFeedImageView.h"
#import <STKit/STKit.h>
@interface STDFeedImageView ()
@property (nonatomic, strong) UIView * selectedView;
@end
@implementation STDFeedImageView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.selectedView = [[UIView alloc] initWithFrame:self.bounds];
self.selectedView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.selectedView.hidden = YES;
self.selectedView.backgroundColor = [UIColor st_colorWithRGB:0x0 alpha:0.5];
[self addSubview:self.selectedView];
}
return self;
}
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
self.selectedView.hidden = NO;
}
- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesCancelled:touches withEvent:event];
self.selectedView.hidden = YES;
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
self.selectedView.hidden = YES;
}
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedItem.h
================================================
//
// STDFeedItem.h
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import <STKit/STKit.h>
@interface STDFeedItem : STObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *thumbURLString;
@property (nonatomic, copy) NSString *imageURLString;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
// 评分
@property (nonatomic, assign) CGFloat rate;
- (STImageItem *)imageItem;
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedItem.m
================================================
//
// STDFeedItem.m
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDFeedItem.h"
@implementation STDFeedItem
+ (NSDictionary *) relationship {
return @{@"thumbURLString":@"thumb", @"imageURLString":@"photo"};
}
- (STImageItem *) imageItem {
STImageItem * imageItem = [[STImageItem alloc] init];
imageItem.imageURLString = self.imageURLString;
imageItem.thumbURLString = self.thumbURLString;
return imageItem;
}
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedViewController.h
================================================
//
// STDFeedViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
#import "STDFeedItem.h"
typedef void(^ STDFeedLoadHandler) (NSArray * feeds, BOOL hasMore, NSError * error);
@interface STDFeedViewController : STDViewController
@property (nonatomic, assign) BOOL automaticallyFetchRemoteData;
@property (nonatomic, strong) UICollectionView * collectionView;
@property (nonatomic, weak, readonly) STRefreshControl * refreshControl;
@property (nonatomic, strong, readonly) NSMutableArray * feeds;
@property (nonatomic, assign, readonly) NSTimeInterval previousRequestTime;
@property (nonatomic, assign, readonly) BOOL loading;
- (void) loadDataFromCacheWithHandler:(STDFeedLoadHandler) completionHandler;
- (void) loadDataWithPage:(NSInteger) page
size:(NSInteger) size
completionHandler:(STDFeedLoadHandler) completionHandler;
- (void) saveDataToCache:(NSArray *) feeds;
- (NSString *) cacheIdentifier;
@end
extern NSInteger const STDFeedLoadPageSize;
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDFeedViewController.m
================================================
//
// STDFeedViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-9-26.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDFeedViewController.h"
#import "STDFeedCell.h"
#import "STDRefreshControl.h"
@interface STDFeedViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, STImagePresentDelegate>
@property (nonatomic, assign) NSInteger page;
@property (nonatomic, weak) STRefreshControl * refreshControl;
@property (nonatomic, strong) NSMutableArray * feeds;
@property (nonatomic, assign) BOOL hasMore;
@property (nonatomic, assign) NSTimeInterval previousRequestTime;
@property (nonatomic, strong) STScrollDirector * collectionDirector;
@end
@implementation STDFeedViewController
- (instancetype) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.collectionDirector = [[STScrollDirector alloc] init];
STDRefreshControl *refreshControl = [[STDRefreshControl alloc] initWithFrame:CGRectMake(0, 0, 200, 76)];
refreshControl.threshold = 76;
// self.collectionDirector.refreshControl = refreshControl;
[self.collectionDirector setTitle:@"加载更多" forState:STScrollDirectorStatePaginationNormal];
[self.collectionDirector setTitle:@"正在加载更多" forState:STScrollDirectorStatePaginationLoading];
[self.collectionDirector setTitle:@"重新加载" forState:STScrollDirectorStatePaginationFailed];
[self.collectionDirector setTitle:@"没有更多了" forState:STScrollDirectorStatePaginationReachedEnd];
self.feeds = [NSMutableArray arrayWithCapacity:5];
self.automaticallyFetchRemoteData = YES;
self.hidesBottomBarWhenPushed = YES;
}
return self;
}
- (void) viewDidLoad {
[super viewDidLoad];
[self loadDataFromCacheWithHandler:^(NSArray *feeds, BOOL hasMore, NSError *error) {
[self.feeds addObjectsFromArray:feeds];
}];
STCollectionViewFlowLayout * collectionViewFlowLayout = [[STCollectionViewFlowLayout alloc] init];
collectionViewFlowLayout.minimumInteritemSpacing = 0;
collectionViewFlowLayout.minimumLineSpacing = 0;
collectionViewFlowLayout.numberOfColumns = [self preferredNumberOfColumnsWithWidth:CGRectGetWidth(self.view.frame)];
UICollectionView * collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:collectionViewFlowLayout];
collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
collectionView.backgroundView = nil;
collectionView.backgroundColor = [UIColor st_colorWithRGB:0xCCCCCC];
collectionView.dataSource = self;
collectionView.delegate = self;
[collectionView registerClass:[STDFeedCell class] forCellWithReuseIdentifier:@"Identifier"];
[self.view addSubview:collectionView];
self.collectionView = collectionView;
self.collectionDirector.scrollView = collectionView;
[self.collectionDirector.refreshControl addTarget:self action:@selector(refreshControlActionFired:) forControlEvents:UIControlEventValueChanged];
[self.collectionDirector.paginationControl addTarget:self action:@selector(paginationControlActionFired:) forControlEvents:UIControlEventValueChanged];
self.refreshControl = self.collectionDirector.refreshControl;
[self.refreshControl beginRefreshing];
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// NSTimeInterval timeInterval = [[NSDate date] timeIntervalSince1970];
// if (((timeInterval - self.previousRequestTime) > 300 || self.feeds.count == 0) && !self.refreshControl.isRefreshing && self.automaticallyFetchRemoteData) {
// [self.refreshControl beginRefreshing];
// }
}
- (void)GIFGeneratorActionFired:(id) sender {
NSInteger maximumCount = 5;
STGIFGenerator *generator = [[STGIFGenerator alloc] init];
[self.feeds enumerateObjectsUsingBlock:^(STDFeedItem * obj, NSUInteger idx, BOOL *stop) {
UIImage *image = [STImageCache cachedImageForKey:obj.thumbURLString];
[generator appendImage:image duration:1];
if (idx == maximumCount) {
*stop = YES;
}
}];
[generator startGeneratorWithPath:nil completionHandler:^(NSString *path) {
NSLog(@"%@", path);
}];
}
- (void) refreshControlActionFired:(id) sender {
self.page = 0;
__weak STDFeedViewController * weakSelf = self;
[self loadDataWithPage:0 size:STDFeedLoadPageSize completionHandler:^(NSArray *feeds, BOOL hasMore, NSError *error) {
if (!error) {
[weakSelf.feeds removeAllObjects];
[weakSelf.feeds addObjectsFromArray:feeds];
weakSelf.hasMore = hasMore;
[weakSelf reloadCollectionFooterView];
weakSelf.previousRequestTime = [[NSDate date] timeIntervalSince1970];
NSString * cacheKey = [NSString stringWithFormat:@"%@-LastRequest", [self cacheIdentifier]].st_md5String;
[[STPersistence standardPersistence] setValue:@(weakSelf.previousRequestTime) forKey:cacheKey];
[weakSelf.collectionView reloadData];
[weakSelf saveDataToCache:feeds];
}
[weakSelf.collectionDirector.refreshControl endRefreshing];
}];
}
- (void) saveDataToCache:(NSArray *) feeds {
NSMutableArray * result = [NSMutableArray arrayWithCapacity:5];
[feeds enumerateObjectsUsingBlock:^(STDFeedItem * obj, NSUInteger idx, BOOL *stop) {
[result addObject:[obj toDictionary]];
}];
NSString * cacheKey = [NSString stringWithFormat:@"%@-CachedData", [self cacheIdentifier]].st_md5String;
[[STPersistence cachePersistenceWithSubpath:@"FeedCache"] setValue:result forKey:cacheKey];
}
- (void) reloadCollectionFooterView {
if (self.hasMore) {
self.collectionDirector.paginationControl.paginationState = STPaginationControlStateNormal;
} else {
self.collectionDirector.paginationControl.paginationState = STPaginationControlStateReachedEnd;
}
self.collectionView.collectionFooterView = self.collectionDirector.paginationControl;
}
- (void) paginationControlActionFired:(id) sender {
self.page ++;
__weak STDFeedViewController * weakSelf = self;
[self loadDataWithPage:self.page size:STDFeedLoadPageSize completionHandler:^(NSArray *feeds, BOOL hasMore, NSError *error) {
if (!error) {
[weakSelf.feeds addObjectsFromArray:feeds];
weakSelf.hasMore = hasMore;
[weakSelf reloadCollectionFooterView];
[weakSelf.collectionView reloadData];
}
}];
}
- (void)loadDataFromCacheWithHandler:(STDFeedLoadHandler) completionHandler {
NSMutableArray * result = [NSMutableArray arrayWithCapacity:5];
NSString * cacheKey = [NSString stringWithFormat:@"%@-CachedData", [self cacheIdentifier]].st_md5String;
NSArray * cachedData = [[STPersistence cachePersistenceWithSubpath:@"FeedCache"] valueForKey:cacheKey];
if ([cachedData isKindOfClass:[NSArray class]]) {
[cachedData enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
STDFeedItem * feedItem = [[STDFeedItem alloc] initWithDictionary:obj];
[result addObject:feedItem];
}];
}
if (completionHandler) {
completionHandler(result, NO,nil);
}
}
- (void) loadDataWithPage:(NSInteger) page
size:(NSInteger) size
completionHandler:(STDFeedLoadHandler) completionHandler {
completionHandler(nil, NO,nil);
}
#pragma mark - UICollectionViewDataSource
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.feeds.count;
}
- (UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
STDFeedCell * collectionCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Identifier" forIndexPath:indexPath];
collectionCell.feedItem = self.feeds[indexPath.row];
return collectionCell;
}
- (void) collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSMutableArray * images = [NSMutableArray arrayWithCapacity:2];
[self.feeds enumerateObjectsUsingBlock:^(STDFeedItem * obj, NSUInteger idx, BOOL *stop) {
[images addObject:obj.imageItem];
}];
STImagePresent * imagePresent = [[STImagePresent alloc] initWithImages:images];
imagePresent.delegate = self;
[imagePresent presentImageAtIndex:indexPath.row animated:YES];
}
#pragma mark - STCollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(STCollectionViewFlowLayout *) collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
STDFeedItem * feedItem = self.feeds[indexPath.row];
NSInteger numberOfColumns = collectionViewLayout.numberOfColumns;
if (numberOfColumns * feedItem.width * feedItem.height == 0) {
return CGSizeZero;
}
CGFloat width = CGRectGetWidth(collectionView.bounds) / numberOfColumns;
CGFloat height = [STDFeedCell heightForCollectionCellWithFeedItem:feedItem constrainedToWidth:width];
return CGSizeMake(width, height);
}
#pragma mark - STImagePresent
- (void) imagePresent:(STImagePresent *) imagePresent didPresentImageAtIndex:(NSInteger) index {
NSIndexPath * indexPath = [NSIndexPath indexPathForItem:index inSection:0];
if (![self.collectionView cellForItemAtIndexPath:indexPath]) {
[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];
}
}
- (UIImageView *) imagePresent:(STImagePresent *) imagePresent imageViewForImageAtIndex:(NSInteger) index {
NSIndexPath * indexPath = [NSIndexPath indexPathForItem:index inSection:0];
STDFeedCell * collectionViewCell = (STDFeedCell *)[self.collectionView cellForItemAtIndexPath:indexPath];
return collectionViewCell.imageView;
}
#pragma mark - Private
- (void) reloadCollectionFooterView:(UIView *) footerView {
self.collectionView.collectionFooterView = footerView;
}
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
STCollectionViewFlowLayout * flowLayout = (STCollectionViewFlowLayout *) self.collectionView.collectionViewLayout;
flowLayout.numberOfColumns = [self preferredNumberOfColumnsWithWidth:CGRectGetWidth(self.view.frame)];
[self.collectionView reloadData];
}
- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
STCollectionViewFlowLayout * flowLayout = (STCollectionViewFlowLayout *) self.collectionView.collectionViewLayout;
flowLayout.numberOfColumns = [self preferredNumberOfColumnsWithWidth:size.width];
[self.collectionView reloadData];
}
- (NSInteger)preferredNumberOfColumnsWithWidth:(CGFloat) width {
if (width == 320) {
return 2;
}
if (width == 375) {
return 3;
}
return width / 160;
}
- (NSString *)cacheIdentifier {
return NSStringFromClass([self class]);
}
- (NSTimeInterval)previousRequestTime {
if (_previousRequestTime == 0) {
NSString * cacheKey = [NSString stringWithFormat:@"%@-LastRequest", [self cacheIdentifier]].st_md5String;
_previousRequestTime = [[[STPersistence standardPersistence] valueForKey:cacheKey] doubleValue];
}
return _previousRequestTime;
}
@end
NSInteger const STDFeedLoadPageSize = 50;
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDownloadViewController.h
================================================
//
// STDownloadViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-3-9.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
@interface STDownloadViewController : STDViewController
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/Image/STDownloadViewController.m
================================================
//
// STDownloadViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-3-9.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDownloadViewController.h"
#import "STAlertView.h"
@interface STDownloadViewController ()
@property (nonatomic, strong) UIImageView * imageView;
@property (nonatomic, strong) STRoundProgressView * roundProgressView;
@property (nonatomic, strong) NSString * thumbURL;
@property (nonatomic, strong) NSString * imageURL;
@end
@implementation STDownloadViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.hidesBottomBarWhenPushed = YES;
self.thumbURL = @"http://lovecard-photo.stor.sinaapp.com/D294D8DFA381405970FA52E579E8A7B2.jpg";
self.imageURL = @"http://lovecard-photo.stor.sinaapp.com/735F748E2F2482591C1DFE1351E622E9.jpg";
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.navigationItem.title = @"图片下载";
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"弹框" target:self action:@selector(alertActionFired:)];
UIView * containerView = [[UIView alloc] initWithFrame:CGRectMake(self.view.width / 2 - 120, 20, 240, 40)];
containerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
[self.view addSubview:containerView];
self.edgesForExtendedLayout = (UIRectEdgeLeft | UIRectEdgeRight);
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 80, 40);
[button addTarget:self action:@selector(downloadImage:) forControlEvents:UIControlEventTouchUpInside];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button setTitle:@"点我下载" forState:UIControlStateNormal];
[containerView addSubview:button];
UIButton * button1 = [UIButton buttonWithType:UIButtonTypeCustom];
button1.frame = CGRectMake(160, 0, 80, 40);
[button1 setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[button1 setTitle:@"清除缓存" forState:UIControlStateNormal];
[button1 addTarget:self action:@selector(cleanCache:) forControlEvents:UIControlEventTouchUpInside];
[containerView addSubview:button1];
self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.width / 2 - 60, 80, 120, 120)];
self.imageView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.userInteractionEnabled = YES;
[self.imageView st_addTouchTarget:self action:@selector(seeBigImage:)];
[self.view addSubview:self.imageView];
self.roundProgressView = [[STRoundProgressView alloc] initWithFrame:CGRectMake(0, 0, 35, 35)];
self.roundProgressView.center = self.imageView.center;
self.roundProgressView.hidden = YES;
[self.imageView addSubview:self.roundProgressView];
}
- (void)alertActionFired:(id)sender {
STAlertView * alertView = [[STAlertView alloc] initWithMenuTitles:@"First", @"Second", @"Third", nil];
__unused NSInteger result = [alertView showInView:self.view animated:YES];
}
- (void) cleanCache:(id) sender {
[STImageCache removeCacheImageForKey:self.thumbURL];
[STImageCache removeCacheImageForKey:self.imageURL];
self.imageView.image = nil;
}
- (void) seeBigImage:(id) sender {
if (self.imageView.image) {
[STImagePresent presentImageView:self.imageView hdImageURL:self.imageURL];
}
}
- (void) downloadImage:(id) sender {
NSString * imageURL = self.thumbURL;
if ([STImageCache hasCachedImageForKey:imageURL]) {
__weak STDownloadViewController * weakSelf = self;
[self.imageView st_setImageWithURLString:imageURL finishedHandler:^(UIImage *image, NSString * URLString, BOOL usingCache, NSError *error) {
weakSelf.imageView.image = image;
}];
return;
}
__weak STDownloadViewController * weakSelf = self;
self.roundProgressView.hidden = NO;
self.roundProgressView.center = CGPointMake(self.imageView.bounds.size.width / 2, self.imageView.bounds.size.height / 2);
[self.imageView st_setImageWithURLString:imageURL progressHandler:^(CGFloat completion) {
weakSelf.roundProgressView.completion = completion;
} finishedHandler:^(UIImage *image, NSString * URLString, BOOL usingCache, NSError *error) {
weakSelf.roundProgressView.hidden = YES;
weakSelf.imageView.image = image;
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/STDImageBlurViewController.h
================================================
//
// STDImageBlurViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-10-12.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDViewController.h"
@interface STDImageBlurViewController : STDViewController
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/STDImageBlurViewController.m
================================================
//
// STDImageBlurViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-10-12.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDImageBlurViewController.h"
#import "MZCroppableView.h"
#import "UIBezierPath-Points.h"
@interface STDImageBlurViewController ()
@property(nonatomic, strong) UIView *containerView;
@property(nonatomic, strong) UIImageView *backgroundImageView;
@property(nonatomic, strong) MZCroppableView *croppableView;
@property(nonatomic, strong) UIImageView *coverImageView;
@end
@implementation STDImageBlurViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.st_interactivePopTransitionOffset = 15;
self.customizeEdgeOffset = NO;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.edgesForExtendedLayout = UIRectEdgeNone;
self.navigationItem.title = @"图片裁剪";
UIView *containerView = [[UIView alloc] initWithFrame:self.view.bounds];
containerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:containerView];
self.containerView = containerView;
UIImage *backgroundImage = [UIImage imageNamed:@"LaunchImage"];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:containerView.bounds];
backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
backgroundImageView.image = backgroundImage;
[containerView addSubview:backgroundImageView];
self.backgroundImageView = backgroundImageView;
self.coverImageView = [[UIImageView alloc] initWithFrame:backgroundImageView.frame];
self.coverImageView.autoresizingMask = backgroundImageView.autoresizingMask;
[containerView addSubview:self.coverImageView];
self.coverImageView.backgroundColor = [UIColor clearColor];
self.coverImageView.hidden = YES;
MZCroppableView *croppableView = [[MZCroppableView alloc] initWithImageView:backgroundImageView];
croppableView.frame = containerView.bounds;
croppableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[containerView addSubview:croppableView];
self.croppableView = croppableView;
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, self.view.height - 44, self.view.width, 44)];
UIBarButtonItem *resetItem =
[[UIBarButtonItem alloc] initWithTitle:@"重置" style:UIBarButtonItemStylePlain target:self action:@selector(resetActionFired:)];
UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:NULL];
UIBarButtonItem *finishItem =
[[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonItemStylePlain target:self action:@selector(finishActionFired:)];
toolbar.items = @[ resetItem, flexibleItem, finishItem ];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:toolbar];
containerView.bottom = toolbar.top;
}
- (void)resetActionFired:(id)sender {
[self.croppableView removeFromSuperview];
MZCroppableView *croppableView = [[MZCroppableView alloc] initWithImageView:self.backgroundImageView];
croppableView.frame = self.containerView.bounds;
croppableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.containerView addSubview:croppableView];
self.croppableView = croppableView;
self.coverImageView.hidden = YES;
}
- (void)finishActionFired:(id)sender {
NSArray *points = [self.croppableView.croppingPath points];
if (!points.count) {
[[[UIAlertView alloc]initWithTitle:@"摸我!" message:@"尝试用手在图片上随便摸两下" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
return;
}
CGSize imageViewSize = self.backgroundImageView.size;
CGSize imageSize = self.backgroundImageView.image.size;
UIBezierPath *aPath = [UIBezierPath bezierPath];
{
// Set the starting point of the shape.
CGPoint p1 = [MZCroppableView convertCGPoint:CGPointFromString(points[0]) fromRect1:imageViewSize toRect2:imageSize];
[aPath moveToPoint:p1];
for (uint i = 1; i < points.count; i++) {
CGPoint p = [MZCroppableView convertCGPoint:CGPointFromString(points[i]) fromRect1:imageViewSize toRect2:imageSize];
[aPath addLineToPoint:p];
}
[aPath closePath];
}
UIImage *blurImage = [self.backgroundImageView.image st_blurImageWithRadius:20. tintColor:nil saturationDeltaFactor:1.3];
UIGraphicsBeginImageContextWithOptions(blurImage.size, NO, [UIScreen mainScreen].scale);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(0, blurImage.size.width, blurImage.size.height, 8, blurImage.size.width * 4, colorSpace,
(CGBitmapInfo)kCGImageAlphaPremultipliedLast);
UIGraphicsPushContext(context);
CGContextDrawImage(context, CGRectMake(0, 0, blurImage.size.width, blurImage.size.height), blurImage.CGImage);
CGContextSetBlendMode(context, (CGBlendMode)kCGBlendModeClear);
CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0 green:0 blue:0 alpha:0].CGColor);
CGContextAddPath(context, aPath.CGPath);
CGContextFillPath(context);
CGImageRef cgImage = CGBitmapContextCreateImage(context);
UIGraphicsEndImageContext();
UIGraphicsPopContext();
[self.croppableView removeFromSuperview];
self.coverImageView.hidden = NO;
self.coverImageView.image = [UIImage imageWithCGImage:cgImage];
CFRelease(cgImage);
CFRelease(context);
CFRelease(colorSpace);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/STDNavigationTestViewController.h
================================================
//
// STDNavigationTestViewController.h
// STKitDemo
//
// Created by SunJiangting on 14-8-25.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDTextTableViewController.h"
@interface STDNavigationTestViewController : STDTextTableViewController
@end
================================================
FILE: STKitDemo/Classes/Modules/Components/STDNavigationTestViewController.m
================================================
//
// STDNavigationTestViewController.m
// STKitDemo
//
// Created by SunJiangting on 14-8-25.
// Copyright (c) 2014年 SunJiangting. All rights reserved.
//
#import "STDNavigationTestViewController.h"
@interface STDNavigationTestViewController () <STNavigationControllerDelegate>
@property (nonatomic, strong) NSArray *dataSource;
@end
@implementation STDNavigationTestViewController
@dynamic dataSource;
-
gitextract_9zbrd07j/
├── .gitignore
├── README.md
├── STKitDemo/
│ ├── Classes/
│ │ ├── 3rdLibs/
│ │ │ ├── MZCroppableView/
│ │ │ │ ├── MZCroppableView.h
│ │ │ │ ├── MZCroppableView.m
│ │ │ │ ├── UIBezierPath-Points.h
│ │ │ │ └── UIBezierPath-Points.m
│ │ │ ├── PingTester/
│ │ │ │ ├── SimplePing.h
│ │ │ │ └── SimplePing.m
│ │ │ └── SphereView/
│ │ │ ├── PFGoldenSectionSpiral.h
│ │ │ ├── PFGoldenSectionSpiral.m
│ │ │ ├── ZYQSphereView.h
│ │ │ └── ZYQSphereView.m
│ │ ├── BaseUI/
│ │ │ ├── STAlertView.h
│ │ │ ├── STAlertView.m
│ │ │ ├── STDCardTransitionDelegate.h
│ │ │ ├── STDCardTransitionDelegate.m
│ │ │ ├── STDCoreDataManager.h
│ │ │ ├── STDCoreDataManager.m
│ │ │ ├── STDLoadingView.h
│ │ │ ├── STDLoadingView.m
│ │ │ ├── STDRefreshControl.h
│ │ │ ├── STDRefreshControl.m
│ │ │ ├── STDRotateTransitionDelegate.h
│ │ │ ├── STDRotateTransitionDelegate.m
│ │ │ ├── STDScrollViewController.h
│ │ │ ├── STDScrollViewController.m
│ │ │ ├── STDTabBarController.h
│ │ │ ├── STDTabBarController.m
│ │ │ ├── STDTableViewController.h
│ │ │ ├── STDTableViewController.m
│ │ │ ├── STDTextTableViewController.h
│ │ │ ├── STDTextTableViewController.m
│ │ │ ├── STDTransitionDelegate.h
│ │ │ ├── STDTransitionDelegate.m
│ │ │ ├── STDViewController.h
│ │ │ ├── STDViewController.m
│ │ │ ├── STDropMenuView.h
│ │ │ ├── STDropMenuView.m
│ │ │ ├── STMenuView.h
│ │ │ ├── STMenuView.m
│ │ │ └── SideBar/
│ │ │ ├── STDLeftViewController.h
│ │ │ ├── STDLeftViewController.m
│ │ │ ├── STDSideBarController.h
│ │ │ └── STDSideBarController.m
│ │ ├── Modules/
│ │ │ ├── Components/
│ │ │ │ ├── Image/
│ │ │ │ │ ├── STDCardViewController.h
│ │ │ │ │ ├── STDCardViewController.m
│ │ │ │ │ ├── STDFeedCell.h
│ │ │ │ │ ├── STDFeedCell.m
│ │ │ │ │ ├── STDFeedImageView.h
│ │ │ │ │ ├── STDFeedImageView.m
│ │ │ │ │ ├── STDFeedItem.h
│ │ │ │ │ ├── STDFeedItem.m
│ │ │ │ │ ├── STDFeedViewController.h
│ │ │ │ │ ├── STDFeedViewController.m
│ │ │ │ │ ├── STDownloadViewController.h
│ │ │ │ │ └── STDownloadViewController.m
│ │ │ │ ├── STDImageBlurViewController.h
│ │ │ │ ├── STDImageBlurViewController.m
│ │ │ │ ├── STDNavigationTestViewController.h
│ │ │ │ ├── STDNavigationTestViewController.m
│ │ │ │ ├── STDScrollViewController.h
│ │ │ │ ├── STDScrollViewController.m
│ │ │ │ ├── STDemoViewController.h
│ │ │ │ ├── STDemoViewController.m
│ │ │ │ └── TextLayout/
│ │ │ │ ├── STDAboutViewController.h
│ │ │ │ ├── STDAboutViewController.m
│ │ │ │ ├── STDLinkViewController.h
│ │ │ │ ├── STDLinkViewController.m
│ │ │ │ ├── STDTextViewController.h
│ │ │ │ └── STDTextViewController.m
│ │ │ ├── DesignPatterns/
│ │ │ │ ├── Creational/
│ │ │ │ │ ├── STDAbstractFactory.h
│ │ │ │ │ ├── STDAbstractFactory.m
│ │ │ │ │ ├── STDBuilder.h
│ │ │ │ │ ├── STDBuilder.m
│ │ │ │ │ ├── STDFactoryMethod.h
│ │ │ │ │ ├── STDFactoryMethod.m
│ │ │ │ │ ├── STDPrototype.h
│ │ │ │ │ ├── STDPrototype.m
│ │ │ │ │ ├── STDSingleton.h
│ │ │ │ │ └── STDSingleton.m
│ │ │ │ ├── STDesignPatterns.h
│ │ │ │ └── Structural/
│ │ │ │ ├── STDAdapter.h
│ │ │ │ ├── STDAdapter.m
│ │ │ │ ├── STDBridge.h
│ │ │ │ ├── STDBridge.m
│ │ │ │ ├── STDFacade.h
│ │ │ │ ├── STDFacade.m
│ │ │ │ ├── STDProxy.h
│ │ │ │ └── STDProxy.m
│ │ │ ├── STDSideBar/
│ │ │ │ ├── STDMapViewController.h
│ │ │ │ ├── STDMapViewController.m
│ │ │ │ └── STDMapViewController.xib
│ │ │ ├── STDStartViewController.h
│ │ │ ├── STDStartViewController.m
│ │ │ ├── Services/
│ │ │ │ ├── Algorithm/
│ │ │ │ │ ├── STACodeViewController.h
│ │ │ │ │ ├── STACodeViewController.m
│ │ │ │ │ ├── STAHanoiOperation.h
│ │ │ │ │ ├── STAHanoiOperation.m
│ │ │ │ │ ├── STAHanoiView.h
│ │ │ │ │ ├── STAHanoiView.m
│ │ │ │ │ ├── STAHanoiViewController.h
│ │ │ │ │ ├── STAHanoiViewController.m
│ │ │ │ │ ├── STARootViewController.h
│ │ │ │ │ ├── STARootViewController.m
│ │ │ │ │ ├── STASortDefines.h
│ │ │ │ │ ├── STASortOperation.h
│ │ │ │ │ ├── STASortOperation.m
│ │ │ │ │ ├── STASortView.h
│ │ │ │ │ ├── STASortView.m
│ │ │ │ │ ├── STASortViewController.h
│ │ │ │ │ └── STASortViewController.m
│ │ │ │ ├── BookReader/
│ │ │ │ │ ├── STDBookViewController.h
│ │ │ │ │ ├── STDBookViewController.m
│ │ │ │ │ ├── STDReaderViewController.h
│ │ │ │ │ ├── STDReaderViewController.m
│ │ │ │ │ ├── STRichView.h
│ │ │ │ │ ├── STRichView.m
│ │ │ │ │ └── book.txt
│ │ │ │ ├── CoreData/
│ │ │ │ │ ├── Entity/
│ │ │ │ │ │ ├── STDEntityDefines.h
│ │ │ │ │ │ ├── STDImage.h
│ │ │ │ │ │ ├── STDImage.m
│ │ │ │ │ │ ├── STDMessage.h
│ │ │ │ │ │ ├── STDMessage.m
│ │ │ │ │ │ ├── STDSession.h
│ │ │ │ │ │ ├── STDSession.m
│ │ │ │ │ │ ├── STDUser.h
│ │ │ │ │ │ └── STDUser.m
│ │ │ │ │ ├── STDBaseChatCell.h
│ │ │ │ │ ├── STDBaseChatCell.m
│ │ │ │ │ ├── STDChat.h
│ │ │ │ │ ├── STDChat.m
│ │ │ │ │ ├── STDChatInputView.h
│ │ │ │ │ ├── STDChatInputView.m
│ │ │ │ │ ├── STDChatViewController.h
│ │ │ │ │ ├── STDChatViewController.m
│ │ │ │ │ ├── STDImageChatCell.h
│ │ │ │ │ ├── STDImageChatCell.m
│ │ │ │ │ ├── STDModel.xcdatamodeld/
│ │ │ │ │ │ ├── .xccurrentversion
│ │ │ │ │ │ ├── STDModel 2.xcdatamodel/
│ │ │ │ │ │ │ └── contents
│ │ │ │ │ │ └── STDModel.xcdatamodel/
│ │ │ │ │ │ └── contents
│ │ │ │ │ ├── STDTextChatCell.h
│ │ │ │ │ └── STDTextChatCell.m
│ │ │ │ ├── Recorder/
│ │ │ │ │ ├── SCSiriWaveformView.h
│ │ │ │ │ ├── SCSiriWaveformView.m
│ │ │ │ │ ├── STDAboutAudioViewController.h
│ │ │ │ │ ├── STDAboutAudioViewController.m
│ │ │ │ │ ├── STDRecordViewController.h
│ │ │ │ │ ├── STDRecordViewController.m
│ │ │ │ │ ├── STWaveBarView.h
│ │ │ │ │ └── STWaveBarView.m
│ │ │ │ ├── STDServiceViewController.h
│ │ │ │ └── STDServiceViewController.m
│ │ │ └── Settings/
│ │ │ ├── Debug/
│ │ │ │ ├── STDAuthorization.h
│ │ │ │ ├── STDAuthorization.m
│ │ │ │ ├── STDDebugPingViewController.h
│ │ │ │ ├── STDDebugPingViewController.m
│ │ │ │ ├── STDLocationPickerController.h
│ │ │ │ ├── STDLocationPickerController.m
│ │ │ │ ├── STDPingServices.h
│ │ │ │ ├── STDPingServices.m
│ │ │ │ ├── STDebugFoundation.h
│ │ │ │ └── STDebugFoundation.m
│ │ │ ├── STDButton.h
│ │ │ ├── STDButton.m
│ │ │ ├── STDFontViewController.h
│ │ │ ├── STDFontViewController.m
│ │ │ ├── STDMoreViewController.h
│ │ │ ├── STDMoreViewController.m
│ │ │ ├── STDNavigationSettingViewController.h
│ │ │ ├── STDNavigationSettingViewController.m
│ │ │ ├── STDNavigationSettingViewController.xib
│ │ │ ├── STDSettingViewController.h
│ │ │ └── STDSettingViewController.m
│ │ └── STKit.framework/
│ │ ├── Headers/
│ │ │ ├── Foundation+STKit.h
│ │ │ ├── NSData+STGZip.h
│ │ │ ├── STAESCryptor.h
│ │ │ ├── STAlbumManager.h
│ │ │ ├── STApplicationContext.h
│ │ │ ├── STAudioCenter.h
│ │ │ ├── STAudioRecorder.h
│ │ │ ├── STButton.h
│ │ │ ├── STCategories.h
│ │ │ ├── STCollectionViewFlowLayout.h
│ │ │ ├── STControlDefines.h
│ │ │ ├── STCoreDataManager.h
│ │ │ ├── STDefines.h
│ │ │ ├── STGIFGenerator.h
│ │ │ ├── STHTTPConfiguration.h
│ │ │ ├── STHTTPNetwork.h
│ │ │ ├── STHTTPOperation.h
│ │ │ ├── STHTTPRequest.h
│ │ │ ├── STImage.h
│ │ │ ├── STImageCache.h
│ │ │ ├── STImageCollectionView.h
│ │ │ ├── STImageLoader.h
│ │ │ ├── STImagePickerController.h
│ │ │ ├── STImagePresent.h
│ │ │ ├── STImageScrollView.h
│ │ │ ├── STImageView.h
│ │ │ ├── STImageViewController.h
│ │ │ ├── STIndicatorView.h
│ │ │ ├── STJavaScriptBridge.h
│ │ │ ├── STKeychain.h
│ │ │ ├── STKit.h
│ │ │ ├── STLabel.h
│ │ │ ├── STLinkLabel.h
│ │ │ ├── STLocationManager.h
│ │ │ ├── STModel.h
│ │ │ ├── STModelViewController.h
│ │ │ ├── STNavigationBar.h
│ │ │ ├── STNavigationController.h
│ │ │ ├── STNetworkConfiguration.h
│ │ │ ├── STNotificationWindow.h
│ │ │ ├── STObject.h
│ │ │ ├── STPaginationControl.h
│ │ │ ├── STPayManager.h
│ │ │ ├── STPayViewController.h
│ │ │ ├── STPersistence.h
│ │ │ ├── STPopoverView.h
│ │ │ ├── STRSACryptor.h
│ │ │ ├── STRateControl.h
│ │ │ ├── STReachability.h
│ │ │ ├── STRefreshControl.h
│ │ │ ├── STRoundProgressView.h
│ │ │ ├── STScrollDirector.h
│ │ │ ├── STSearchBar.h
│ │ │ ├── STSearchDisplayController.h
│ │ │ ├── STShadow.h
│ │ │ ├── STSideBarController.h
│ │ │ ├── STStringTokenizer.h
│ │ │ ├── STTabBar.h
│ │ │ ├── STTabBarController.h
│ │ │ ├── STTabBarItem.h
│ │ │ ├── STTableView.h
│ │ │ ├── STTableViewCell.h
│ │ │ ├── STTableViewController.h
│ │ │ ├── STTextView.h
│ │ │ ├── STTheme.h
│ │ │ ├── STThemeManager.h
│ │ │ ├── STTrashManager.h
│ │ │ ├── STURLCache.h
│ │ │ ├── STViewController.h
│ │ │ ├── STWaveAnalysis.h
│ │ │ ├── STWebViewController.h
│ │ │ ├── STZipArchive.h
│ │ │ ├── UIAlertView+STBlock.h
│ │ │ ├── UIImageView+STImageLoader.h
│ │ │ ├── UIKit+STKit.h
│ │ │ ├── UIView+STConstraint.h
│ │ │ └── fft.h
│ │ ├── Info.plist
│ │ └── STKit
│ ├── LaunchScreen.xib
│ ├── Main.storyboard
│ ├── Resources/
│ │ └── licenses.html
│ ├── STDAppDelegate.h
│ ├── STDAppDelegate.m
│ ├── STDemoImages.xcassets/
│ │ ├── AppIcon.appiconset/
│ │ │ └── Contents.json
│ │ ├── Base/
│ │ │ ├── avatar72.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── navigation.imageset/
│ │ │ └── Contents.json
│ │ ├── Chat/
│ │ │ ├── bubble_image_green.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_image_white.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_text_green.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── bubble_text_white.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── chat_input_send_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── chat_input_send_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── FeedCell/
│ │ │ ├── feed_cell_background.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── feed_cell_border.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── feed_hot_icon.imageset/
│ │ │ └── Contents.json
│ │ ├── LaunchImage.launchimage/
│ │ │ └── Contents.json
│ │ ├── Navigation/
│ │ │ ├── nav_cancel_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_done_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_menu_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── nav_refresh_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── nav_setting_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── Porn/
│ │ │ ├── article_collect.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── article_collected.imageset/
│ │ │ └── Contents.json
│ │ ├── Publish/
│ │ │ ├── choose_image_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── choose_image_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── hud_done.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── product_default.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── publish_button_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── publish_button_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── publish_tool_bkg.imageset/
│ │ │ └── Contents.json
│ │ ├── SearchBar/
│ │ │ ├── search_cancel_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── search_cancel_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── searchbar_bkg.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── textfield_delete_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── SideBar/
│ │ │ ├── SideBarAvatar_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarAvatar_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarNearby_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarNearby_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarSetting_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarSetting_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── SideBarShare_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── SideBarShare_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── TabBar/
│ │ │ ├── tab_bkg.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_message_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_message_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_profile_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_profile_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_receipt_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_receipt_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── tab_service_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── tab_service_normal.imageset/
│ │ │ └── Contents.json
│ │ ├── Test/
│ │ │ ├── button_bkg_highlighted.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── button_bkg_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── home_search_left_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── home_search_right_normal.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── search_history_edit.imageset/
│ │ │ └── Contents.json
│ │ ├── UIControls/
│ │ │ ├── Menu/
│ │ │ │ ├── wormhole0.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole1.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole2.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole3.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── wormhole4.imageset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── wormhole5.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── aero_button.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── viewer_zoom_in.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── viewer_zoom_out.imageset/
│ │ │ └── Contents.json
│ │ ├── ViewController/
│ │ │ ├── left_account_header.imageset/
│ │ │ │ └── Contents.json
│ │ │ └── left_bkg.imageset/
│ │ │ └── Contents.json
│ │ └── terms.imageset/
│ │ └── Contents.json
│ ├── STKitDemo-Info.plist
│ ├── STKitDemo-Prefix.pch
│ ├── STKitDemo.entitlements
│ ├── STKitDemoInHouse-Info.plist
│ ├── Settings.bundle/
│ │ ├── Root.plist
│ │ └── en.lproj/
│ │ └── Root.strings
│ ├── en.lproj/
│ │ └── InfoPlist.strings
│ └── main.m
├── STKitDemo.xcodeproj/
│ └── project.pbxproj
├── STKitDemoTests/
│ ├── DesignPatterns/
│ │ └── Creational/
│ │ ├── STDAbstractFactoryTests.m
│ │ ├── STDFactoryMethodTests.m
│ │ └── STDSingletonTests.m
│ ├── Info.plist
│ └── STKitDemoTests.m
└── STKitWidget/
├── Info.plist
├── MainInterface.storyboard
├── STKitWidgetInHouse-Info.plist
├── TodayViewController.h
└── TodayViewController.m
SYMBOL INDEX (56 symbols across 35 files)
FILE: STKitDemo/Classes/3rdLibs/MZCroppableView/MZCroppableView.h
function interface (line 11) | interface MZCroppableView : UIView
FILE: STKitDemo/Classes/3rdLibs/PingTester/SimplePing.h
type IPHeader (line 74) | struct IPHeader {
type IPHeader (line 88) | typedef struct IPHeader IPHeader;
type ICMPHeader (line 100) | struct ICMPHeader {
type ICMPHeader (line 108) | typedef struct ICMPHeader ICMPHeader;
function interface (line 112) | interface SimplePing : NSObject
type ICMPHeader (line 151) | struct ICMPHeader
FILE: STKitDemo/Classes/3rdLibs/SphereView/PFGoldenSectionSpiral.h
type Float32 (line 20) | typedef Float32 STFloat32;
type PFMatrix (line 22) | struct PFMatrix {
type PFMatrix (line 29) | typedef struct PFMatrix PFMatrix;
type PFAxisDirection (line 32) | typedef enum {
type PFPoint (line 41) | struct PFPoint {
type PFPoint (line 46) | typedef struct PFPoint PFPoint;
function interface (line 49) | interface PFGoldenSectionSpiral : NSObject {
FILE: STKitDemo/Classes/3rdLibs/SphereView/ZYQSphereView.h
function interface (line 11) | interface ZYQSphereView : UIView {
FILE: STKitDemo/Classes/Modules/Services/Algorithm/STASortDefines.h
type STAlgorithmType (line 12) | typedef enum STAlgorithmType {
FILE: STKitDemo/Classes/Modules/Services/Algorithm/STASortOperation.h
type STSortOperationType (line 13) | typedef enum STSortOperationType {
FILE: STKitDemo/Classes/Modules/Services/Algorithm/STASortViewController.h
type STArraySortType (line 14) | typedef enum STArraySortType {
FILE: STKitDemo/Classes/Modules/Services/CoreData/Entity/STDEntityDefines.h
type STDMessageType (line 12) | typedef enum {
FILE: STKitDemo/Classes/Modules/Services/CoreData/STDChat.h
type STDChatViewDirection (line 11) | typedef enum STDChatViewDirection {
FILE: STKitDemo/Classes/Modules/Services/Recorder/STWaveBarView.h
type SWaveStyleBar (line 15) | typedef NS_ENUM(NSInteger, STWaveStyle) {
FILE: STKitDemo/Classes/Modules/Settings/Debug/STDAuthorization.h
type STAuthorizationOperation (line 15) | typedef enum {
type STAutomicAuthorizationTime (line 24) | typedef enum {
FILE: STKitDemo/Classes/Modules/Settings/Debug/STDPingServices.h
type STDPingStatusDidStart (line 12) | typedef NS_ENUM(NSInteger, STDPingStatus) {
FILE: STKitDemo/Classes/STKit.framework/Headers/Foundation+STKit.h
function end (line 109) | end
FILE: STKitDemo/Classes/STKit.framework/Headers/STAudioRecorder.h
type STAudioRecorderBegan (line 14) | typedef NS_ENUM(NSInteger, STAudioRecorderState) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STControlDefines.h
type STRefreshControlStateNormal (line 19) | typedef NS_ENUM(NSInteger, STRefreshControlState) {
type STPaginationControlStateNormal (line 33) | typedef NS_ENUM(NSInteger, STPaginationControlState) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STDefines.h
function ST_INLINE (line 88) | ST_INLINE CGFloat STDistanceBetweenPoints(CGPoint point1, CGPoint point2) {
type STRange (line 94) | typedef struct _STRange {
function ST_INLINE (line 106) | ST_INLINE STRange STRangeMake(NSInteger start, NSInteger end) {
function ST_INLINE (line 119) | ST_INLINE BOOL STIsInRange(STRange r, NSInteger i) { return (r.start <= ...
function ST_INLINE (line 125) | ST_INLINE BOOL CGPointInRect(CGPoint p, CGRect r) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STGIFGenerator.h
type STGIFPropertyColorModelRGB (line 14) | typedef NS_ENUM(NSInteger, STGIFPropertyColorModel) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STHTTPConfiguration.h
type STHTTPRequestFormEnctypeURLEncoded (line 14) | typedef NS_ENUM(NSInteger, STHTTPRequestFormEnctype) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STHTTPOperation.h
function interface (line 50) | interface STHTTPOperation : NSOperation {
FILE: STKitDemo/Classes/STKit.framework/Headers/STImageCache.h
type STIdentifier (line 11) | typedef long long STIdentifier;
FILE: STKitDemo/Classes/STKit.framework/Headers/STImageLoader.h
type STImageDownloadOrderForward (line 34) | typedef NS_ENUM(NSInteger, STImageDownloadOrder) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STImageView.h
type STImageViewState (line 12) | typedef enum STImageViewState {
FILE: STKitDemo/Classes/STKit.framework/Headers/STIndicatorView.h
type STIndicatorTypeCustom (line 12) | typedef NS_ENUM(NSInteger, STIndicatorType) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STLabel.h
type STVerticalAlignment (line 12) | typedef enum {
FILE: STKitDemo/Classes/STKit.framework/Headers/STLinkLabel.h
function ST_INLINE (line 15) | ST_INLINE BOOL STLocationInRange(NSRange range, NSUInteger location) {
function ST_INLINE (line 21) | ST_INLINE BOOL STRangeContainsRange(NSRange range1, NSRange range2) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STModel.h
type STModelDataSourceTypeCache (line 15) | typedef NS_ENUM(NSInteger, STModelDataSourceType) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STNavigationController.h
type STViewControllerTransitionTypePush (line 14) | typedef NS_ENUM(NSInteger, STViewControllerTransitionType) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STPayManager.h
type STPayResultSuccess (line 12) | typedef NS_ENUM(NSInteger, STPayResult) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STPersistence.h
type STPersistenceDirectoryDocument (line 12) | typedef NS_ENUM(NSInteger, STPersistenceDirectory) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STPopoverView.h
type STPopoverViewDirectionUp (line 12) | typedef NS_ENUM(NSInteger, STPopoverViewDirection) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STReachability.h
type STNetworkStatusReachNone (line 12) | typedef NS_ENUM(NSInteger, STNetworkStatus) {
FILE: STKitDemo/Classes/STKit.framework/Headers/STWaveAnalysis.h
type STAnalysisBuffer (line 17) | typedef struct STAnalysisBuffer {
type STAnalysisBuffer (line 22) | typedef STAnalysisBuffer *STAnalysisBufferRef;
FILE: STKitDemo/Classes/STKit.framework/Headers/STZipArchive.h
function interface (line 11) | interface STZipArchive : NSObject {
FILE: STKitDemo/Classes/STKit.framework/Headers/UIImageView+STImageLoader.h
type STImageStateInitialized (line 14) | typedef NS_ENUM(NSInteger, STImageState) {
FILE: STKitDemo/Classes/STKit.framework/Headers/fft.h
type sound_sample (line 33) | typedef short int sound_sample;
type _struct_fft_state (line 35) | struct _struct_fft_state {
type fft_state (line 50) | typedef struct _struct_fft_state fft_state;
Condensed preview — 341 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,051K chars).
[
{
"path": ".gitignore",
"chars": 128,
"preview": "*.DS_Store\n*.swp\n*project.xcworkspace\n*contents.xcworkspacedata\n*.xcuserdata*\n*xcuserdata*\n.DS_Store\nxcuserdata/\nxcshare"
},
{
"path": "README.md",
"chars": 1233,
"preview": "A demo of the STKit. Download[STKit](https://github.com/lovesunstar/STKit)\n\nSTKit is a collection of useful classes for "
},
{
"path": "STKitDemo/Classes/3rdLibs/MZCroppableView/MZCroppableView.h",
"chars": 732,
"preview": "//\n// MZCroppableView.h\n// MZCroppableView\n//\n// Created by macbook on 30/10/2013.\n// Copyright (c) 2013 macbook. Al"
},
{
"path": "STKitDemo/Classes/3rdLibs/MZCroppableView/MZCroppableView.m",
"chars": 5140,
"preview": "//\n// MZCroppableView.m\n// MZCroppableView\n//\n// Created by macbook on 30/10/2013.\n// Copyright (c) 2013 macbook. Al"
},
{
"path": "STKitDemo/Classes/3rdLibs/MZCroppableView/UIBezierPath-Points.h",
"chars": 572,
"preview": "/*\n Erica Sadun, http://ericasadun.com\n iPhone Developer's Cookbook, 6.x Edition\n BSD License, Use at your own risk\n */\n"
},
{
"path": "STKitDemo/Classes/3rdLibs/MZCroppableView/UIBezierPath-Points.m",
"chars": 6339,
"preview": "/*\n Erica Sadun, http://ericasadun.com\n iPhone Developer's Cookbook, 6.x Edition\n BSD License, Use at your own risk\n */\n"
},
{
"path": "STKitDemo/Classes/3rdLibs/PingTester/SimplePing.h",
"chars": 9065,
"preview": "/*\n File: SimplePing.h\n\n Contains: Implements ping.\n\n Written by: DTS\n\n Copyright: Copyright (c) 20"
},
{
"path": "STKitDemo/Classes/3rdLibs/PingTester/SimplePing.m",
"chars": 22168,
"preview": "/*\n File: SimplePing.m\n\n Contains: Implements ping.\n\n Written by: DTS\n\n Copyright: Copyright (c) 20"
},
{
"path": "STKitDemo/Classes/3rdLibs/SphereView/PFGoldenSectionSpiral.h",
"chars": 3035,
"preview": "//This file is part of SphereView.\n//\n//SphereView is free software: you can redistribute it and/or modify\n//it under th"
},
{
"path": "STKitDemo/Classes/3rdLibs/SphereView/PFGoldenSectionSpiral.m",
"chars": 8188,
"preview": "//This file is part of SphereView.\n//\n//SphereView is free software: you can redistribute it and/or modify\n//it under th"
},
{
"path": "STKitDemo/Classes/3rdLibs/SphereView/ZYQSphereView.h",
"chars": 631,
"preview": "//\n// ZYQSphereView.h\n// SphereViewSample\n//\n// Created by Zhao Yiqi on 13-12-8.\n// Copyright (c) 2013年 Zhao Yiqi. A"
},
{
"path": "STKitDemo/Classes/3rdLibs/SphereView/ZYQSphereView.m",
"chars": 9488,
"preview": "//\n// ZYQSphereView.m\n// SphereViewSample\n//\n// Created by Zhao Yiqi on 13-12-8.\n// Copyright (c) 2013年 Zhao Yiqi. A"
},
{
"path": "STKitDemo/Classes/BaseUI/STAlertView.h",
"chars": 361,
"preview": "//\n// STAlertView.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-28.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/BaseUI/STAlertView.m",
"chars": 9207,
"preview": "//\n// STAlertView.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-28.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/BaseUI/STDCardTransitionDelegate.h",
"chars": 256,
"preview": "//\n// STDCardTransitionDelegate.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 SunJi"
},
{
"path": "STKitDemo/Classes/BaseUI/STDCardTransitionDelegate.m",
"chars": 4826,
"preview": "//\n// STDCardTransitionDelegate.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 SunJi"
},
{
"path": "STKitDemo/Classes/BaseUI/STDCoreDataManager.h",
"chars": 295,
"preview": "//\n// STDCoreDataManager.h\n// STKitDemo\n//\n// Created by SunJiangting on 15/8/11.\n// Copyright (c) 2015年 SunJiangtin"
},
{
"path": "STKitDemo/Classes/BaseUI/STDCoreDataManager.m",
"chars": 658,
"preview": "//\n// STDCoreDataManager.m\n// STKitDemo\n//\n// Created by SunJiangting on 15/8/11.\n// Copyright (c) 2015年 SunJiangtin"
},
{
"path": "STKitDemo/Classes/BaseUI/STDLoadingView.h",
"chars": 322,
"preview": "//\n// STDLoadingView.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-2.\n// Copyright (c) 2015年 SunJiangting. Al"
},
{
"path": "STKitDemo/Classes/BaseUI/STDLoadingView.m",
"chars": 3415,
"preview": "//\n// STDLoadingView.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-2.\n// Copyright (c) 2015年 SunJiangting. Al"
},
{
"path": "STKitDemo/Classes/BaseUI/STDRefreshControl.h",
"chars": 225,
"preview": "//\n// STDRefreshControl.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-2.\n// Copyright (c) 2015年 SunJiangting."
},
{
"path": "STKitDemo/Classes/BaseUI/STDRefreshControl.m",
"chars": 1363,
"preview": "//\n// TTRefreshControl.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-2.\n// Copyright (c) 2015年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/BaseUI/STDRotateTransitionDelegate.h",
"chars": 260,
"preview": "//\n// STDRotateTransitionDelegate.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 Sun"
},
{
"path": "STKitDemo/Classes/BaseUI/STDRotateTransitionDelegate.m",
"chars": 2209,
"preview": "//\n// STDRotateTransitionDelegate.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 Sun"
},
{
"path": "STKitDemo/Classes/BaseUI/STDScrollViewController.h",
"chars": 335,
"preview": "//\n// STDScrollViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-7.\n// Copyright (c) 2015年 SunJian"
},
{
"path": "STKitDemo/Classes/BaseUI/STDScrollViewController.m",
"chars": 5709,
"preview": "//\n// STDScrollViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-7.\n// Copyright (c) 2015年 SunJian"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTabBarController.h",
"chars": 232,
"preview": "//\n// STDTabBarController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-18.\n// Copyright (c) 2014年 SunJiangti"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTabBarController.m",
"chars": 4480,
"preview": "//\n// STDTabBarController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-18.\n// Copyright (c) 2014年 SunJiangti"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTableViewController.h",
"chars": 594,
"preview": "//\n// STDTableViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJia"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTableViewController.m",
"chars": 6612,
"preview": "//\n// STDTableViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJia"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTextTableViewController.h",
"chars": 1067,
"preview": "//\n// STDTextTableViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-10-12.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTextTableViewController.m",
"chars": 5017,
"preview": "//\n// STDTextTableViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-10-12.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTransitionDelegate.h",
"chars": 291,
"preview": "//\n// STDTransitionDelegate.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 SunJiangt"
},
{
"path": "STKitDemo/Classes/BaseUI/STDTransitionDelegate.m",
"chars": 1151,
"preview": "//\n// STDTransitionDelegate.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-4-3.\n// Copyright (c) 2015年 SunJiangt"
},
{
"path": "STKitDemo/Classes/BaseUI/STDViewController.h",
"chars": 307,
"preview": "//\n// STDViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJiangtin"
},
{
"path": "STKitDemo/Classes/BaseUI/STDViewController.m",
"chars": 6471,
"preview": "//\n// STDViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJiangtin"
},
{
"path": "STKitDemo/Classes/BaseUI/STDropMenuView.h",
"chars": 412,
"preview": "//\n// STDropMenuView.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-14.\n// Copyright (c) 2014年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/BaseUI/STDropMenuView.m",
"chars": 5182,
"preview": "//\n// STDropMenuView.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-14.\n// Copyright (c) 2014年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/BaseUI/STMenuView.h",
"chars": 1137,
"preview": "//\n// STMenuView.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-24.\n// Copyright (c) 2014年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/BaseUI/STMenuView.m",
"chars": 14027,
"preview": "//\n// STMenuView.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-24.\n// Copyright (c) 2014年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/BaseUI/SideBar/STDLeftViewController.h",
"chars": 242,
"preview": "//\n// STDLeftViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/BaseUI/SideBar/STDLeftViewController.m",
"chars": 6274,
"preview": "//\n// STDLeftViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/BaseUI/SideBar/STDSideBarController.h",
"chars": 246,
"preview": "//\n// STDSideBarController.h\n// STKit\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/BaseUI/SideBar/STDSideBarController.m",
"chars": 2205,
"preview": "//\n// STDSideBarController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-20.\n// Copyright (c) 2013年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDCardViewController.h",
"chars": 257,
"preview": "//\n// STDCardViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDCardViewController.m",
"chars": 1922,
"preview": "//\n// STDCardViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedCell.h",
"chars": 593,
"preview": "//\n// STDFeedCell.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedCell.m",
"chars": 7202,
"preview": "//\n// STDFeedCell.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedImageView.h",
"chars": 289,
"preview": "//\n// STDFeedImageView.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedImageView.m",
"chars": 1299,
"preview": "//\n// STDFeedImageView.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedItem.h",
"chars": 563,
"preview": "//\n// STDFeedItem.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedItem.m",
"chars": 523,
"preview": "//\n// STDFeedItem.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedViewController.h",
"chars": 1154,
"preview": "//\n// STDFeedViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDFeedViewController.m",
"chars": 11935,
"preview": "//\n// STDFeedViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-9-26.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDownloadViewController.h",
"chars": 246,
"preview": "//\n// STDownloadViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-9.\n// Copyright (c) 2014年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Components/Image/STDownloadViewController.m",
"chars": 4901,
"preview": "//\n// STDownloadViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-9.\n// Copyright (c) 2014年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDImageBlurViewController.h",
"chars": 252,
"preview": "//\n// STDImageBlurViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-10-12.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDImageBlurViewController.m",
"chars": 6534,
"preview": "//\n// STDImageBlurViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-10-12.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDNavigationTestViewController.h",
"chars": 279,
"preview": "//\n// STDNavigationTestViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-25.\n// Copyright (c) 2014"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDNavigationTestViewController.m",
"chars": 4426,
"preview": "//\n// STDNavigationTestViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-25.\n// Copyright (c) 2014"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDScrollViewController.h",
"chars": 244,
"preview": "//\n// STDScrollViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDScrollViewController.m",
"chars": 2260,
"preview": "//\n// STDScrollViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDemoViewController.h",
"chars": 257,
"preview": "//\n// STDemoViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-20.\n// Copyright (c) 2014年 SunJiangt"
},
{
"path": "STKitDemo/Classes/Modules/Components/STDemoViewController.m",
"chars": 11125,
"preview": "//\n// STDemoViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-20.\n// Copyright (c) 2014年 SunJiangt"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDAboutViewController.h",
"chars": 244,
"preview": "//\n// STDAboutViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDAboutViewController.m",
"chars": 6087,
"preview": "//\n// STDAboutViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDLinkViewController.h",
"chars": 252,
"preview": "//\n// STDLinkViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-12-24.\n// Copyright (c) 2014年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDLinkViewController.m",
"chars": 6609,
"preview": "//\n// STDLinkViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-12-24.\n// Copyright (c) 2014年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDTextViewController.h",
"chars": 241,
"preview": "//\n// STDTextViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-5-12.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Components/TextLayout/STDTextViewController.m",
"chars": 1835,
"preview": "//\n// STDTextViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-5-12.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDAbstractFactory.h",
"chars": 729,
"preview": "//\n// STDAbstractFactory.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDAbstractFactory.m",
"chars": 1068,
"preview": "//\n// STDAbstractFactory.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDBuilder.h",
"chars": 672,
"preview": "//\n// STDBuilder.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDBuilder.m",
"chars": 1999,
"preview": "//\n// STDBuilder.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDFactoryMethod.h",
"chars": 426,
"preview": "//\n// STDFactoryMethod.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDFactoryMethod.m",
"chars": 588,
"preview": "//\n// STDFactoryMethod.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDPrototype.h",
"chars": 398,
"preview": "//\n// STDPrototype.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDPrototype.m",
"chars": 1617,
"preview": "//\n// STDPrototype.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDSingleton.h",
"chars": 385,
"preview": "//\n// STDSingleton.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Creational/STDSingleton.m",
"chars": 675,
"preview": "//\n// STDSingleton.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/STDesignPatterns.h",
"chars": 445,
"preview": "//\n// STDesignPatterns.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-3.\n// Copyright (c) 2015年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDAdapter.h",
"chars": 670,
"preview": "//\n// STDAdapter.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDAdapter.m",
"chars": 1165,
"preview": "//\n// STDAdapter.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDBridge.h",
"chars": 233,
"preview": "//\n// STDBridge.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-9.\n// Copyright (c) 2015年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDBridge.m",
"chars": 216,
"preview": "//\n// STDBridge.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-9.\n// Copyright (c) 2015年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDFacade.h",
"chars": 536,
"preview": "//\n// STDFacade.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-5.\n// Copyright (c) 2015年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDFacade.m",
"chars": 1557,
"preview": "//\n// STDFacade.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-5.\n// Copyright (c) 2015年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDProxy.h",
"chars": 426,
"preview": "//\n// STDProxy.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-5.\n// Copyright (c) 2015年 SunJiangting. All righ"
},
{
"path": "STKitDemo/Classes/Modules/DesignPatterns/Structural/STDProxy.m",
"chars": 1121,
"preview": "//\n// STDProxy.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-5.\n// Copyright (c) 2015年 SunJiangting. All righ"
},
{
"path": "STKitDemo/Classes/Modules/STDSideBar/STDMapViewController.h",
"chars": 238,
"preview": "//\n// STDMapViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-9.\n// Copyright (c) 2014年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/STDSideBar/STDMapViewController.m",
"chars": 1971,
"preview": "//\n// STDMapViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-9.\n// Copyright (c) 2014年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/STDSideBar/STDMapViewController.xib",
"chars": 2428,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" versi"
},
{
"path": "STKitDemo/Classes/Modules/STDStartViewController.h",
"chars": 267,
"preview": "//\n// STDStartViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-20.\n// Copyright (c) 2014年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/STDStartViewController.m",
"chars": 4222,
"preview": "//\n// STDStartViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-2-20.\n// Copyright (c) 2014年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STACodeViewController.h",
"chars": 352,
"preview": "//\n// STACodeViewController.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-4.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STACodeViewController.m",
"chars": 3376,
"preview": "//\n// STACodeViewController.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-4.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiOperation.h",
"chars": 449,
"preview": "//\n// STAHanoiOperation.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiOperation.m",
"chars": 987,
"preview": "//\n// STAHanoiOperation.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiView.h",
"chars": 517,
"preview": "//\n// STAHanoiView.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiView.m",
"chars": 7367,
"preview": "//\n// STAHanoiView.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiViewController.h",
"chars": 349,
"preview": "//\n// STAHanoiViewController.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangt"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STAHanoiViewController.m",
"chars": 4047,
"preview": "//\n// STHanoiViewController.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-3.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STARootViewController.h",
"chars": 309,
"preview": "//\n// STARootViewController.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STARootViewController.m",
"chars": 7462,
"preview": "//\n// STARootViewController.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortDefines.h",
"chars": 467,
"preview": "//\n// STASortDefines.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. "
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortOperation.h",
"chars": 874,
"preview": "//\n// STSortOperation.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangting. Al"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortOperation.m",
"chars": 2060,
"preview": "//\n// STASortOperation.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortView.h",
"chars": 1659,
"preview": "//\n// STASortView.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortView.m",
"chars": 7509,
"preview": "//\n// STASortView.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-2.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortViewController.h",
"chars": 647,
"preview": "//\n// STASortViewController.h\n// STBasic\n//\n// Created by SunJiangting on 13-11-1.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/Algorithm/STASortViewController.m",
"chars": 13136,
"preview": "//\n// STASortViewController.m\n// STBasic\n//\n// Created by SunJiangting on 13-11-1.\n// Copyright (c) 2013年 SunJiangti"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STDBookViewController.h",
"chars": 681,
"preview": "//\n// STDBookViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-31.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STDBookViewController.m",
"chars": 3974,
"preview": "//\n// STDBookViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-31.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STDReaderViewController.h",
"chars": 427,
"preview": "//\n// STDReaderViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-31.\n// Copyright (c) 2013年 SunJi"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STDReaderViewController.m",
"chars": 10584,
"preview": "//\n// STDReaderViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-31.\n// Copyright (c) 2013年 SunJi"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STRichView.h",
"chars": 357,
"preview": "//\n// STRichView.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-6-5.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/STRichView.m",
"chars": 2473,
"preview": "//\n// STRichView.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-6-5.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/BookReader/book.txt",
"chars": 26420,
"preview": "令狐冲和盈盈出得山谷,行了半日,来到一处市镇,到一家面店吃面。令狐冲筷子上挑起长长几根面条,笑吟吟的道:“我和你还没拜堂成亲……”盈盈登时羞得满脸通红,嗔道:“谁和你拜堂成亲了?”令狐冲微笑道:“将来总是要成亲的。你如不愿,我捉住了你拜堂。"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDEntityDefines.h",
"chars": 337,
"preview": "//\n// STDEntityDefines.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-19.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDImage.h",
"chars": 422,
"preview": "//\n// STDImage.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDImage.m",
"chars": 264,
"preview": "//\n// STDImage.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDMessage.h",
"chars": 738,
"preview": "//\n// STDMessage.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDMessage.m",
"chars": 371,
"preview": "//\n// STDMessage.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDSession.h",
"chars": 254,
"preview": "//\n// STDSession.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDSession.m",
"chars": 200,
"preview": "//\n// STDSession.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDUser.h",
"chars": 453,
"preview": "//\n// STDUser.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/Entity/STDUser.m",
"chars": 252,
"preview": "//\n// STDUser.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDBaseChatCell.h",
"chars": 969,
"preview": "//\n// STDBaseChatCell.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDBaseChatCell.m",
"chars": 3805,
"preview": "//\n// STDBaseChatCell.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChat.h",
"chars": 874,
"preview": "//\n// STDChat.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-19.\n// Copyright (c) 2013年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChat.m",
"chars": 6702,
"preview": "//\n// STDChat.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-19.\n// Copyright (c) 2013年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChatInputView.h",
"chars": 904,
"preview": "//\n// STDChatInputView.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-24.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChatInputView.m",
"chars": 10325,
"preview": "//\n// STDChatInputView.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-24.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChatViewController.h",
"chars": 553,
"preview": "//\n// STDChatViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDChatViewController.m",
"chars": 23710,
"preview": "//\n// STDChatViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDImageChatCell.h",
"chars": 228,
"preview": "//\n// STDImageChatCell.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-19.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDImageChatCell.m",
"chars": 2173,
"preview": "//\n// STDImageChatCell.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-19.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDModel.xcdatamodeld/.xccurrentversion",
"chars": 263,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDModel.xcdatamodeld/STDModel 2.xcdatamodel/contents",
"chars": 4036,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<model userDefinedModelVersionIdentifier=\"\" type=\"com.apple.IDEC"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDModel.xcdatamodeld/STDModel.xcdatamodel/contents",
"chars": 3101,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<model userDefinedModelVersionIdentifier=\"\" type=\"com.apple.IDEC"
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDTextChatCell.h",
"chars": 229,
"preview": "//\n// STDTextChatCell.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Services/CoreData/STDTextChatCell.m",
"chars": 3734,
"preview": "//\n// STDTextChatCell.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-18.\n// Copyright (c) 2013年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/SCSiriWaveformView.h",
"chars": 1645,
"preview": "//\n// SCSiriWaveformView.h\n// SCSiriWaveformView\n//\n// Created by Stefan Ceriu on 12/04/2014.\n// Copyright (c) 2014 "
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/SCSiriWaveformView.m",
"chars": 2800,
"preview": "//\n// SCSiriWaveformView.m\n// SCSiriWaveformView\n//\n// Created by Stefan Ceriu on 12/04/2014.\n// Copyright (c) 2014 "
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STDAboutAudioViewController.h",
"chars": 253,
"preview": "//\n// STDAboutAudioViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-5-10.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STDAboutAudioViewController.m",
"chars": 1765,
"preview": "//\n// STDAboutAudioViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-5-10.\n// Copyright (c) 2014年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STDRecordViewController.h",
"chars": 246,
"preview": "//\n// STDRecordViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJi"
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STDRecordViewController.m",
"chars": 4073,
"preview": "//\n// STDRecordViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJi"
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STWaveBarView.h",
"chars": 972,
"preview": "//\n// STWaveBarView.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-3-22.\n// Copyright (c) 2013年 sun. All rights "
},
{
"path": "STKitDemo/Classes/Modules/Services/Recorder/STWaveBarView.m",
"chars": 8712,
"preview": "//\n// STWaveBarView.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-3-22.\n// Copyright (c) 2013年 sun. All rights "
},
{
"path": "STKitDemo/Classes/Modules/Services/STDServiceViewController.h",
"chars": 288,
"preview": "//\n// STDServiceViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-8.\n// Copyright (c) 2014年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Services/STDServiceViewController.m",
"chars": 4540,
"preview": "//\n// STDServiceViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-3-8.\n// Copyright (c) 2014年 SunJia"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDAuthorization.h",
"chars": 1003,
"preview": "//\n// STDAuthorization.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-28.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDAuthorization.m",
"chars": 8895,
"preview": "//\n// STDAuthorization.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-11-28.\n// Copyright (c) 2013年 SunJiangting"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDDebugPingViewController.h",
"chars": 250,
"preview": "//\n// STDDebugPingViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJ"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDDebugPingViewController.m",
"chars": 3442,
"preview": "//\n// STDDebugPingViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJ"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDLocationPickerController.h",
"chars": 366,
"preview": "//\n// STDLocationPickerController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-27.\n// Copyright (c) 2015年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDLocationPickerController.m",
"chars": 5938,
"preview": "//\n// STDLocationPickerController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-27.\n// Copyright (c) 2015年 Su"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDPingServices.h",
"chars": 1144,
"preview": "//\n// STDPingServices.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDPingServices.m",
"chars": 7108,
"preview": "//\n// STDPingServices.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDebugFoundation.h",
"chars": 317,
"preview": "//\n// STDebugFoundation.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Settings/Debug/STDebugFoundation.m",
"chars": 1272,
"preview": "//\n// STDebugFoundation.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-9.\n// Copyright (c) 2015年 SunJiangting."
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDButton.h",
"chars": 202,
"preview": "//\n// STDButton.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-31.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDButton.m",
"chars": 365,
"preview": "//\n// STDButton.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-31.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDFontViewController.h",
"chars": 234,
"preview": "//\n// STDFontViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-31.\n// Copyright (c) 2015年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDFontViewController.m",
"chars": 195,
"preview": "//\n// STDFontViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-3-31.\n// Copyright (c) 2015年 SunJiang"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDMoreViewController.h",
"chars": 260,
"preview": "//\n// STDMoreViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDMoreViewController.m",
"chars": 4948,
"preview": "//\n// STDMoreViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 13-12-27.\n// Copyright (c) 2013年 SunJian"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDNavigationSettingViewController.h",
"chars": 267,
"preview": "//\n// STDNavigationSettingViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-17.\n// Copyright (c) 2"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDNavigationSettingViewController.m",
"chars": 2665,
"preview": "//\n// STDNavigationSettingViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 14-8-17.\n// Copyright (c) 2"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDNavigationSettingViewController.xib",
"chars": 9520,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" versi"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDSettingViewController.h",
"chars": 398,
"preview": "//\n// STDSettingViewController.h\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-15.\n// Copyright (c) 2015年 SunJi"
},
{
"path": "STKitDemo/Classes/Modules/Settings/STDSettingViewController.m",
"chars": 8761,
"preview": "//\n// STDSettingViewController.m\n// STKitDemo\n//\n// Created by SunJiangting on 15-2-15.\n// Copyright (c) 2015年 SunJi"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/Foundation+STKit.h",
"chars": 8096,
"preview": "//\n// Foundation+STKit.h\n// STKit\n//\n// Created by SunJiangting on 13-10-5.\n// Copyright (c) 2013年 SunJiangting. All"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/NSData+STGZip.h",
"chars": 395,
"preview": "//\n// NSData+STGZip.h\n// STKit\n//\n// Created by SunJiangting on 15-3-26.\n// Copyright (c) 2015年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STAESCryptor.h",
"chars": 2206,
"preview": "//\n// STAESCryptor.h\n// STKit\n//\n// Created by SunJiangting on 14-9-19.\n// Copyright (c) 2014年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STAlbumManager.h",
"chars": 1066,
"preview": "//\n// STAlbumManager.h\n// STKit\n//\n// Created by SunJiangting on 14-9-28.\n// Copyright (c) 2014年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STApplicationContext.h",
"chars": 1119,
"preview": "//\n// STApplicationContext.h\n// STKit\n//\n// Created by SunJiangting on 14-8-14.\n// Copyright (c) 2014年 SunJiangting."
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STAudioCenter.h",
"chars": 1041,
"preview": "//\n// STAudioCenter.h\n// STKit\n//\n// Created by SunJiangting on 13-10-5.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STAudioRecorder.h",
"chars": 2081,
"preview": "//\n// STAudioRecorder.h\n// STKit\n//\n// Created by SunJiangting on 13-10-5.\n// Copyright (c) 2013年 SunJiangting. All "
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STButton.h",
"chars": 694,
"preview": "//\n// STButton.h\n// STKit\n//\n// Created by SunJiangting on 14-3-25.\n// Copyright (c) 2014年 SunJiangting. All rights "
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STCategories.h",
"chars": 244,
"preview": "//\n// STCategories.h\n// STKit\n//\n// Created by SunJiangting on 14-10-31.\n// Copyright (c) 2014年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STCollectionViewFlowLayout.h",
"chars": 1165,
"preview": "//\n// STCollectionViewFlowLayout.h\n// STKit\n//\n// Created by SunJiangting on 14-5-8.\n// Copyright (c) 2014年 SunJiang"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STControlDefines.h",
"chars": 1550,
"preview": "//\n// STControlDefines.h\n// STKit\n//\n// Created by SunJiangting on 14-9-17.\n// Copyright (c) 2014年 SunJiangting. All"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STCoreDataManager.h",
"chars": 2272,
"preview": "//\n// STCoreDataManager.h\n// STKit\n//\n// Created by SunJiangting on 13-10-5.\n// Copyright (c) 2013年 SunJiangting. Al"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STDefines.h",
"chars": 3161,
"preview": "//\n// STDefines.h\n// STKit\n//\n// Created by SunJiangting on 13-11-27.\n// Copyright (c) 2013年 SunJiangting. All right"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STGIFGenerator.h",
"chars": 1250,
"preview": "//\n// STGIFGenerator.h\n// STKit\n//\n// Created by SunJiangting on 14-11-8.\n// Copyright (c) 2014年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STHTTPConfiguration.h",
"chars": 2273,
"preview": "//\n// STHTTPConfiguration.h\n// STKit\n//\n// Created by SunJiangting on 15-2-6.\n// Copyright (c) 2015年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STHTTPNetwork.h",
"chars": 2732,
"preview": "//\n// STHTTPNetwork.h\n// STKit\n//\n// Created by SunJiangting on 13-11-25.\n// Copyright (c) 2013年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STHTTPOperation.h",
"chars": 4897,
"preview": "//\n// STHTTPOperation.h\n// STKit\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STHTTPRequest.h",
"chars": 3502,
"preview": "//\n// STHTTPRequest.h\n// STKit\n//\n// Created by SunJiangting on 15-2-4.\n// Copyright (c) 2015年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImage.h",
"chars": 413,
"preview": "//\n// STImage.h\n// STKit\n//\n// Created by SunJiangting on 14-11-8.\n// Copyright (c) 2014年 SunJiangting. All rights r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageCache.h",
"chars": 1538,
"preview": "//\n// STImageCache.h\n// STKit\n//\n// Created by SunJiangting on 13-12-17.\n// Copyright (c) 2013年 SunJiangting. All ri"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageCollectionView.h",
"chars": 1527,
"preview": "//\n// STImageCollectionView.h\n// STKit\n//\n// Created by SunJiangting on 14-8-25.\n// Copyright (c) 2014年 SunJiangting"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageLoader.h",
"chars": 1820,
"preview": "//\n// STImageLoader.h\n// STKit\n//\n// Created by SunJiangting on 13-10-29.\n// Copyright (c) 2013年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImagePickerController.h",
"chars": 2034,
"preview": "//\n// STImagePickerController.h\n// STKit\n//\n// Created by SunJiangting on 14-1-3.\n// Copyright (c) 2014年 SunJiangtin"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImagePresent.h",
"chars": 1264,
"preview": "//\n// STImagePresent.h\n// STKit\n//\n// Created by SunJiangting on 14-9-21.\n// Copyright (c) 2014年 SunJiangting. All r"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageScrollView.h",
"chars": 967,
"preview": "//\n// STImageScrollView.h\n// STKit\n//\n// Created by SunJiangting on 13-12-25.\n// Copyright (c) 2013年 SunJiangting. A"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageView.h",
"chars": 1112,
"preview": "//\n// STImageView.h\n// STKit\n//\n// Created by SunJiangting on 13-11-26.\n// Copyright (c) 2013年 SunJiangting. All rig"
},
{
"path": "STKitDemo/Classes/STKit.framework/Headers/STImageViewController.h",
"chars": 1017,
"preview": "//\n// STImageViewController.h\n// STKit\n//\n// Created by SunJiangting on 13-12-25.\n// Copyright (c) 2013年 SunJiangtin"
}
]
// ... and 141 more files (download for full content)
About this extraction
This page contains the full source code of the lovesunstar/stkitdemo GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 341 files (42.0 MB), approximately 274.8k tokens, and a symbol index with 56 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.