Skip to content

Commit

Permalink
1.0.0版
Browse files Browse the repository at this point in the history
1.0.0版
  • Loading branch information
张雷 committed Apr 5, 2016
1 parent 475d256 commit 8597e2b
Show file tree
Hide file tree
Showing 32 changed files with 1,381 additions and 1 deletion.
379 changes: 379 additions & 0 deletions CutterTest.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions CutterTest/AppDelegate.h
@@ -0,0 +1,16 @@
//
// AppDelegate.h
// CutterTest
//
// Created by 张雷 on 16/4/5.
// Copyright © 2016年 zhanglei. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

25 changes: 25 additions & 0 deletions CutterTest/AppDelegate.m
@@ -0,0 +1,25 @@
//
// AppDelegate.m
// CutterTest
//
// Created by 张雷 on 16/4/5.
// Copyright © 2016年 zhanglei. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"%@",NSHomeDirectory());

return YES;
}

@end
38 changes: 38 additions & 0 deletions CutterTest/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
42 changes: 42 additions & 0 deletions CutterTest/Base.lproj/LaunchScreen.storyboard
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cutter" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yrF-Fn-oMc">
<rect key="frame" x="0.0" y="20" width="320" height="548"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="xb3-aO-Qok" firstAttribute="top" secondItem="yrF-Fn-oMc" secondAttribute="bottom" id="8tI-GK-SeC"/>
<constraint firstItem="yrF-Fn-oMc" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="GaB-jk-FtG"/>
<constraint firstAttribute="trailing" secondItem="yrF-Fn-oMc" secondAttribute="trailing" id="LeS-8F-uK9"/>
<constraint firstItem="yrF-Fn-oMc" firstAttribute="top" secondItem="Llm-lL-Icb" secondAttribute="bottom" id="fgr-1K-5G0"/>
</constraints>
</view>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
47 changes: 47 additions & 0 deletions CutterTest/Base.lproj/Main.storyboard
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="4Zi-4y-e4L">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="mjR-Ag-9DB"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1113" y="310"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="gLg-N7-6Ic">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="4Zi-4y-e4L" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="vib-lN-KVs">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="tik-8f-M7F"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="3kq-hc-JTU" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="296" y="954"/>
</scene>
</scenes>
</document>
31 changes: 31 additions & 0 deletions CutterTest/Cutter/Cutter.h
@@ -0,0 +1,31 @@
//
// Cutter.h
// ScreenShotTest
//
// Created by 张雷 on 14/10/26.
// Copyright (c) 2014年 zhanglei. All rights reserved.
//

#import "UIView+Cutter.h"
#import "UIScrollView+Cutter.h"

/*
// 使用说明
// 没有导航和tabbar
UIImage *image = [self.view viewCutter];
// 有导航和tabbar
UIImage *image = [self.navigationController.view viewCutter];
// UICollectionView
UIImage *image = [self.collectionView scrollViewCutter];
// UITableView
UIImage *image = [self.tableView scrollViewCutter];
// UIWebView
UIImage *image = [self.webView scrollViewCutter];
*/
21 changes: 21 additions & 0 deletions CutterTest/Cutter/UIScrollView+Cutter.h
@@ -0,0 +1,21 @@
//
// UIScrollView+Cutter.h
// ScreenShotTest
//
// Created by 张雷 on 14/10/26.
// Copyright (c) 2014年 zhanglei. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "Cutter.h"

@interface UIScrollView (Cutter)

/**
* 根据视图尺寸获取视图截屏(一屏无法显示完整),适用于UIScrollView UITableviewView UICollectionView UIWebView
*
* @return UIImage 截取的图片
*/
- (UIImage *)scrollViewCutter;

@end
38 changes: 38 additions & 0 deletions CutterTest/Cutter/UIScrollView+Cutter.m
@@ -0,0 +1,38 @@
//
// UIScrollView+Cutter.m
// ScreenShotTest
//
// Created by 张雷 on 14/10/26.
// Copyright (c) 2014年 zhanglei. All rights reserved.
//

#import "UIScrollView+Cutter.h"

@implementation UIScrollView (Cutter)

/**
* 根据视图尺寸获取视图截屏(一屏无法显示完整),适用于UIScrollView UITableviewView UICollectionView UIWebView
*
* @return UIImage 截取的图片
*/
- (UIImage *)scrollViewCutter
{
//保存
CGPoint savedContentOffset = self.contentOffset;
CGRect savedFrame = self.frame;

self.contentOffset = CGPointZero;
self.frame = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height);

UIImage *image = [self viewCutter];

//还原数据
self.contentOffset = savedContentOffset;
self.frame = savedFrame;

return image;


}

@end
20 changes: 20 additions & 0 deletions CutterTest/Cutter/UIView+Cutter.h
@@ -0,0 +1,20 @@
//
// UIView+Cutter.h
// ScreenShotTest
//
// Created by 张雷 on 16/4/5.
// Copyright © 2016年 zhiyou. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (Cutter)

/**
* 根据视图尺寸获取视图截屏
*
* @return UIImage 截取的图片
*/
- (UIImage*)viewCutter;

@end
28 changes: 28 additions & 0 deletions CutterTest/Cutter/UIView+Cutter.m
@@ -0,0 +1,28 @@
//
// UIView+Cutter.m
// ScreenShotTest
//
// Created by 张雷 on 16/4/5.
// Copyright © 2016年 zhiyou. All rights reserved.
//

#import "UIView+Cutter.h"

@implementation UIView (Cutter)

/**
* 根据视图尺寸获取视图截屏
*
* @return UIImage 截取的图片
*/
- (UIImage*)viewCutter
{
UIGraphicsBeginImageContextWithOptions(self.bounds.size,NO,[[UIScreen mainScreen] scale]);
[self.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage*img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return img;
}

@end
45 changes: 45 additions & 0 deletions CutterTest/Info.plist
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions CutterTest/ShowImageViewController.h
@@ -0,0 +1,15 @@
//
// ShowImageViewController.h
// ScreenShotTest
//
// Created by 张雷 on 14/10/26.
// Copyright (c) 2014年 zhanglei. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ShowImageViewController : UIViewController

@property (nonatomic,retain) UIImage *image;

@end

0 comments on commit 8597e2b

Please sign in to comment.