Skip to content

Commit cfcc40b

Browse files
committed
add custom share view
1 parent d16a9ac commit cfcc40b

File tree

6 files changed

+190
-12
lines changed

6 files changed

+190
-12
lines changed

TYAlertControllerDemo.xcodeproj/project.pbxproj

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
B01448F21BDE4690009E0389 /* SettingModelView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B01448F11BDE4690009E0389 /* SettingModelView.xib */; };
1212
B01448F71BDE50C1009E0389 /* UIImage+ImageEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = B01448F61BDE50C1009E0389 /* UIImage+ImageEffects.m */; };
1313
B01448FA1BDE51DB009E0389 /* TYAlertController+BlurEffects.m in Sources */ = {isa = PBXBuildFile; fileRef = B01448F91BDE51DB009E0389 /* TYAlertController+BlurEffects.m */; };
14+
B01449061BDE57E9009E0389 /* ShareView.m in Sources */ = {isa = PBXBuildFile; fileRef = B01449051BDE57E9009E0389 /* ShareView.m */; };
15+
B01449081BDE5817009E0389 /* ShareView.xib in Resources */ = {isa = PBXBuildFile; fileRef = B01449071BDE5817009E0389 /* ShareView.xib */; };
1416
B0873F0D1BD370C700D2F4D5 /* TYShowAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = B0873F0C1BD370C700D2F4D5 /* TYShowAlertView.m */; };
1517
B08FD7D01BD905EF00B83FF5 /* screen.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B08FD7CF1BD905EF00B83FF5 /* screen.jpg */; };
1618
D35854241B9532D700B5FA1F /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D35854231B9532D700B5FA1F /* main.m */; };
@@ -48,6 +50,9 @@
4850
B01448F61BDE50C1009E0389 /* UIImage+ImageEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+ImageEffects.m"; sourceTree = "<group>"; };
4951
B01448F81BDE51DB009E0389 /* TYAlertController+BlurEffects.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "TYAlertController+BlurEffects.h"; sourceTree = "<group>"; };
5052
B01448F91BDE51DB009E0389 /* TYAlertController+BlurEffects.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "TYAlertController+BlurEffects.m"; sourceTree = "<group>"; };
53+
B01449041BDE57E9009E0389 /* ShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShareView.h; sourceTree = "<group>"; };
54+
B01449051BDE57E9009E0389 /* ShareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ShareView.m; sourceTree = "<group>"; };
55+
B01449071BDE5817009E0389 /* ShareView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ShareView.xib; sourceTree = "<group>"; };
5156
B0873F0B1BD370C700D2F4D5 /* TYShowAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TYShowAlertView.h; sourceTree = "<group>"; };
5257
B0873F0C1BD370C700D2F4D5 /* TYShowAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TYShowAlertView.m; sourceTree = "<group>"; };
5358
B08FD7CF1BD905EF00B83FF5 /* screen.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = screen.jpg; sourceTree = "<group>"; };
@@ -116,6 +121,9 @@
116121
B01448EE1BDE4677009E0389 /* SettingModelView.h */,
117122
B01448EF1BDE4677009E0389 /* SettingModelView.m */,
118123
B01448F11BDE4690009E0389 /* SettingModelView.xib */,
124+
B01449041BDE57E9009E0389 /* ShareView.h */,
125+
B01449051BDE57E9009E0389 /* ShareView.m */,
126+
B01449071BDE5817009E0389 /* ShareView.xib */,
119127
);
120128
name = customAlertView;
121129
sourceTree = "<group>";
@@ -186,7 +194,7 @@
186194
D35854A31B953F3D00B5FA1F /* TYAlertController */ = {
187195
isa = PBXGroup;
188196
children = (
189-
D386E9711B9C162400321875 /* AlertViews */,
197+
D386E9711B9C162400321875 /* AlertView */,
190198
D386E9701B9C15E800321875 /* AlertAimations */,
191199
D35854A41B953FC300B5FA1F /* TYAlertController.h */,
192200
D35854A51B953FC300B5FA1F /* TYAlertController.m */,
@@ -210,7 +218,7 @@
210218
name = AlertAimations;
211219
sourceTree = "<group>";
212220
};
213-
D386E9711B9C162400321875 /* AlertViews */ = {
221+
D386E9711B9C162400321875 /* AlertView */ = {
214222
isa = PBXGroup;
215223
children = (
216224
D3C1A9711B9D16D5009738B0 /* UIView+TYAlertView.h */,
@@ -220,7 +228,7 @@
220228
D3C1A9741B9D1A83009738B0 /* TYAlertView.h */,
221229
D3C1A9751B9D1A83009738B0 /* TYAlertView.m */,
222230
);
223-
name = AlertViews;
231+
name = AlertView;
224232
sourceTree = "<group>";
225233
};
226234
/* End PBXGroup section */
@@ -305,6 +313,7 @@
305313
files = (
306314
D358542D1B9532D700B5FA1F /* Main.storyboard in Resources */,
307315
B08FD7D01BD905EF00B83FF5 /* screen.jpg in Resources */,
316+
B01449081BDE5817009E0389 /* ShareView.xib in Resources */,
308317
D35854321B9532D700B5FA1F /* LaunchScreen.xib in Resources */,
309318
B01448F21BDE4690009E0389 /* SettingModelView.xib in Resources */,
310319
D358542F1B9532D700B5FA1F /* Images.xcassets in Resources */,
@@ -329,6 +338,7 @@
329338
B01448FA1BDE51DB009E0389 /* TYAlertController+BlurEffects.m in Sources */,
330339
B01448F01BDE4677009E0389 /* SettingModelView.m in Sources */,
331340
B01448F71BDE50C1009E0389 /* UIImage+ImageEffects.m in Sources */,
341+
B01449061BDE57E9009E0389 /* ShareView.m in Sources */,
332342
D35854B51B95B7BB00B5FA1F /* TYBaseAnimation.m in Sources */,
333343
D3C1A9761B9D1A83009738B0 /* TYAlertView.m in Sources */,
334344
D37A91E11B9E7B6000C6661A /* UIView+TYAutoLayout.m in Sources */,
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

TYAlertControllerDemo/ShareView.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// ShareView.h
3+
// TYAlertControllerDemo
4+
//
5+
// Created by tanyang on 15/10/26.
6+
// Copyright © 2015年 tanyang. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface ShareView : UIView
12+
13+
@end

TYAlertControllerDemo/ShareView.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// ShareView.m
3+
// TYAlertControllerDemo
4+
//
5+
// Created by tanyang on 15/10/26.
6+
// Copyright © 2015年 tanyang. All rights reserved.
7+
//
8+
9+
#import "ShareView.h"
10+
#import "UIView+TYAlertView.h"
11+
12+
@implementation ShareView
13+
14+
- (IBAction)cancleAction:(id)sender {
15+
// hide view,or dismiss controller
16+
[self hideView];
17+
}
18+
19+
/*
20+
// Only override drawRect: if you perform custom drawing.
21+
// An empty implementation adversely affects performance during animation.
22+
- (void)drawRect:(CGRect)rect {
23+
// Drawing code
24+
}
25+
*/
26+
27+
@end

TYAlertControllerDemo/ShareView.xib

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
3+
<dependencies>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
6+
</dependencies>
7+
<objects>
8+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
9+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
10+
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="ShareView">
11+
<rect key="frame" x="0.0" y="0.0" width="300" height="300"/>
12+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
13+
<subviews>
14+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="XIr-hc-gna">
15+
<rect key="frame" x="38" y="66" width="50" height="66"/>
16+
<animations/>
17+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
18+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
19+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
20+
<state key="normal" title="新浪微博" image="btn_share_sina">
21+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
22+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
23+
</state>
24+
</button>
25+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="分享到" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nzK-K0-iW6">
26+
<rect key="frame" x="123" y="22" width="54" height="18"/>
27+
<animations/>
28+
<fontDescription key="fontDescription" type="system" pointSize="15"/>
29+
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
30+
<nil key="highlightedColor"/>
31+
</label>
32+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="xOF-Jx-1Jt">
33+
<rect key="frame" x="125" y="66" width="50" height="66"/>
34+
<animations/>
35+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
36+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
37+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
38+
<state key="normal" title="QQ空间" image="btn_share_QQ">
39+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
40+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
41+
</state>
42+
</button>
43+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zGB-mJ-D1W">
44+
<rect key="frame" x="20" y="30" width="95" height="1"/>
45+
<animations/>
46+
<color key="backgroundColor" red="0.80000000000000004" green="0.82745098039999998" blue="0.85098039219999999" alpha="1" colorSpace="calibratedRGB"/>
47+
</view>
48+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hEn-2i-BiU">
49+
<rect key="frame" x="212" y="66" width="50" height="66"/>
50+
<animations/>
51+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
52+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
53+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
54+
<state key="normal" title="QQ好友" image="btn_share_QQhaoyou">
55+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
56+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
57+
</state>
58+
</button>
59+
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FuM-xA-mIh">
60+
<rect key="frame" x="185" y="30" width="95" height="1"/>
61+
<animations/>
62+
<color key="backgroundColor" red="0.80000000000000004" green="0.82745098039999998" blue="0.85098039219999999" alpha="1" colorSpace="calibratedRGB"/>
63+
</view>
64+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Kq9-16-RJg">
65+
<rect key="frame" x="38" y="152" width="50" height="66"/>
66+
<animations/>
67+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
68+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
69+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
70+
<state key="normal" title="微信好友" image="btn_share_weixin">
71+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
72+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
73+
</state>
74+
</button>
75+
<button hidden="YES" opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mga-cK-Sh8">
76+
<rect key="frame" x="212" y="152" width="50" height="66"/>
77+
<animations/>
78+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
79+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
80+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
81+
<state key="normal" title="新浪微博" image="btn_share_sina">
82+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
83+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
84+
</state>
85+
</button>
86+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="3bC-ZI-otZ">
87+
<rect key="frame" x="128" y="234" width="44" height="44"/>
88+
<animations/>
89+
<state key="normal" image="btn_share_del">
90+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
91+
</state>
92+
<connections>
93+
<action selector="cancleAction:" destination="iN0-l3-epB" eventType="touchUpInside" id="RUH-5a-GpM"/>
94+
</connections>
95+
</button>
96+
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="99Q-2n-nhD">
97+
<rect key="frame" x="125" y="152" width="50" height="66"/>
98+
<animations/>
99+
<fontDescription key="fontDescription" type="system" pointSize="12"/>
100+
<inset key="titleEdgeInsets" minX="-56" minY="50" maxX="0.0" maxY="0.0"/>
101+
<inset key="imageEdgeInsets" minX="2" minY="0.0" maxX="2" maxY="20"/>
102+
<state key="normal" title="朋友圈" image="btn_share_pengyouquan">
103+
<color key="titleColor" red="0.50196078430000002" green="0.50196078430000002" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
104+
<color key="titleShadowColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
105+
</state>
106+
</button>
107+
</subviews>
108+
<animations/>
109+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
110+
<nil key="simulatedStatusBarMetrics"/>
111+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
112+
</view>
113+
</objects>
114+
<resources>
115+
<image name="btn_share_QQ" width="58" height="58"/>
116+
<image name="btn_share_QQhaoyou" width="58" height="58"/>
117+
<image name="btn_share_del" width="44" height="44"/>
118+
<image name="btn_share_pengyouquan" width="58" height="58"/>
119+
<image name="btn_share_sina" width="58" height="58"/>
120+
<image name="btn_share_weixin" width="58" height="58"/>
121+
</resources>
122+
</document>

TYAlertControllerDemo/ViewController.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "UIView+TYAlertView.h"
1111
#import "TYAlertController+BlurEffects.h"
1212
#import "SettingModelView.h"
13+
#import "ShareView.h"
1314

1415
@interface ViewController ()
1516
@end
@@ -75,13 +76,9 @@ - (IBAction)showActionSheetAction:(id)sender {
7576
}
7677

7778
- (IBAction)blurEffectAlertViewAction:(id)sender {
78-
TYAlertView *alertView = [TYAlertView alertViewWithTitle:@"TYAlertView" message:@"This is a blur effect on background, is beautiful effect"];
79+
ShareView *shareView = [ShareView createViewFromNib];
7980

80-
[alertView addAction:[TYAlertAction actionWithTitle:@"取消" style:TYAlertActionStyleCancle handler:^(TYAlertAction *action) {
81-
NSLog(@"%@",action.title);
82-
}]];
83-
84-
TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:alertView preferredStyle:TYAlertControllerStyleAlert];
81+
TYAlertController *alertController = [TYAlertController alertControllerWithAlertView:shareView preferredStyle:TYAlertControllerStyleAlert];
8582

8683
// blur effect
8784
[alertController setBlurEffectWithView:self.view];
@@ -95,7 +92,7 @@ - (IBAction)costomActonSheetAction:(id)sender {
9592
// customview from xib
9693
SettingModelView *settingModelView = [SettingModelView createViewFromNib];
9794

98-
// fisrt way to show
95+
// fisrt way to show ,use UIView Category
9996
// [settingModelView showInController:self preferredStyle:TYAlertControllerStyleActionSheet backgoundTapDismissEnable:YES];
10097

10198
// second way to show
@@ -117,15 +114,18 @@ - (IBAction)showAlertViewInWindowAction:(id)sender {
117114

118115
}]];
119116

120-
// first way to show
117+
// first way to show ,use UIView Category
121118
[alertView showInWindowWithOriginY:200 backgoundTapDismissEnable:YES];
122119

123120
// second way to show
124121
//[TYShowAlertView showAlertViewWithView:alertView originY:200 backgoundTapDismissEnable:YES];
125122
}
126123

127124
- (IBAction)customViewInWindowAction:(id)sender {
128-
125+
ShareView *shareView = [ShareView createViewFromNib];
126+
127+
// use UIView Category
128+
[shareView showInWindow];
129129
}
130130

131131
- (void)didReceiveMemoryWarning {

0 commit comments

Comments
 (0)