├── .gitignore ├── LICENSE ├── README.md ├── SCAdView.podspec ├── SCAdView ├── SCAdCollectionViewLayout.h ├── SCAdCollectionViewLayout.m ├── SCAdView.h ├── SCAdView.m └── SCAdViewRenderDelegate.h ├── SCAdViewDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SCAdViewDemo ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Contents.json │ ├── 刘备.imageset │ │ ├── Contents.json │ │ └── 刘备.jpg │ ├── 嬴政.imageset │ │ ├── Contents.json │ │ └── 嬴政.jpg │ ├── 李白.imageset │ │ ├── Contents.json │ │ └── 李白.jpg │ └── 韩信.imageset │ │ ├── Contents.json │ │ └── 韩信.jpg ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── HeroModel.h ├── HeroModel.m ├── Info.plist ├── SCAdDemoCollectionViewCell.h ├── SCAdDemoCollectionViewCell.m ├── SCAdDemoCollectionViewCell.xib ├── ViewController.h ├── ViewController.m └── main.m ├── SCAdViewDemoTests ├── Info.plist └── SCAdViewDemoTests.m └── SCAdViewDemoUITests ├── Info.plist └── SCAdViewDemoUITests.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 陈小翰 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # SCAdView 4 | [![Version](https://img.shields.io/cocoapods/v/SCAdView.svg?style=flat)](http://cocoadocs.org/docsets/SCAdView) 5 | [![Platform](https://img.shields.io/badge/platform-iOS%207%2B-blue.svg?style=flat)](http://cocoadocs.org/docsets/SCAdView) 6 | 7 | `无限轮播图` 8 | 9 | `3D轮播图` 10 | 11 | `广告轮播图` 12 | 13 | ## Statement 14 | If my code can help you even a little bit , please click `star` . Thanks for your support , your star is my motivation. 15 | 16 | ## Introduction 17 | [SCAdView](https://github.com/Chan4iOS/SCAdView) is a carousel control which support the vertical or horizontal scrolling direction, finite / infinite loop carousel , with both 2D plane effect or 3D zoom effect. 18 | 19 | ## Installation 20 | ##### Manual installation 21 | [download](https://github.com/Chan4iOS/SCAdView) the code and unzip,then copy `SCAdView` directory into your project. 22 | ##### CocoaPods 23 | create or modify your podfile: 24 | ``` 25 | pod 'SCAdView' 26 | ``` 27 | and then `pod install` 28 | 29 | ## Usage 30 | The [SCAdView](https://github.com/Chan4iOS/SCAdView) should be created by a `SCAdViewBuilder`,we can customize [SCAdView](https://github.com/Chan4iOS/SCAdView) by modifying a builder's property. 31 | **eg.** 32 | ``` 33 | SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) { 34 | builder.adArray = arrayFromService; 35 | builder.viewFrame = (CGRect){0,100,self.view.bounds.size.width,self.view.bounds.size.width/2.f}; 36 | builder.adItemSize = (CGSize){self.view.bounds.size.width/2.5f,self.view.bounds.size.width/4.f}; 37 | builder.minimumLineSpacing = 0; 38 | builder.secondaryItemMinAlpha = 0.6; 39 | builder.threeDimensionalScale = 1.45; 40 | builder.itemCellNibName = @"SCAdDemoCollectionViewCell"; 41 | }]; 42 | ``` 43 | ## About SCAdViewBuilder 44 | Please read SCAdViewBuilder's interface in `SCAdView.h` file. 45 | 46 | ## Effects 47 | 48 | ![Horizontal scrolling](http://upload-images.jianshu.io/upload_images/2170902-d1adf340ae56286b.gif?imageMogr2/auto-orient/strip) 49 | 50 | 51 | ![Vertical scrolling](http://upload-images.jianshu.io/upload_images/2170902-8971e30031675097.gif?imageMogr2/auto-orient/strip) 52 | 53 | # SCAdView 54 | ## 前言 55 | 如果我的代码能帮助到你哪怕是一点点,请点一下star。谢谢你的支持,你的star是我的动力。 56 | ## 介绍 57 | [SCAdView](https://github.com/Chan4iOS/SCAdView) 是一个支持2D平面效果和3D缩放效果 , 可定制上下左右方向滚动 , 有限/无限循环 轮播的轮播控件 58 | ## 安装 59 | ##### 手动安装 60 | [下载](https://github.com/Chan4iOS/SCAdView)源代码并解压,将目录下`SCAdView`文件夹添加到你的项目中 61 | ##### CocoaPods 62 | 创建或在你的 podfile中添加: 63 | ``` 64 | pod 'SCAdView' 65 | ``` 66 | 然后到终端cd到目录下执行 `pod install` 67 | 68 | ## 用法 69 | 在使用的时候,我们应该通过一个`SCAdViewBuilder`对象来构造出[SCAdView](https://github.com/Chan4iOS/SCAdView),而我们可以通过在构造方法中修改buidler中的属性,来定制一个我们想要的 [SCAdView](https://github.com/Chan4iOS/SCAdView) 70 | **eg.** 71 | ``` 72 | SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) { 73 | builder.adArray = arrayFromService; 74 | builder.viewFrame = (CGRect){0,100,self.view.bounds.size.width,self.view.bounds.size.width/2.f}; 75 | builder.adItemSize = (CGSize){self.view.bounds.size.width/2.5f,self.view.bounds.size.width/4.f}; 76 | builder.minimumLineSpacing = 0; 77 | builder.secondaryItemMinAlpha = 0.6; 78 | builder.threeDimensionalScale = 1.45; 79 | builder.itemCellNibName = @"SCAdDemoCollectionViewCell"; 80 | }]; 81 | ``` 82 | #### SCAdViewBuilder 的详解 83 | 请到`SCAdView.h`文件查阅SCAdViewBuilder的 interface。 84 | 85 | ## 效果 86 | ![水平滚动效果](http://upload-images.jianshu.io/upload_images/2170902-d1adf340ae56286b.gif?imageMogr2/auto-orient/strip) 87 | 88 | ![垂直滚动效果](http://upload-images.jianshu.io/upload_images/2170902-8971e30031675097.gif?imageMogr2/auto-orient/strip) 89 | -------------------------------------------------------------------------------- /SCAdView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'SCAdView' 3 | s.version = '0.62' 4 | s.summary = '一个支持2D平面 , 3D缩放 , 上下左右方向滚动 , 有限/无限循环 轮播的轮播控件 A carousel control which support the vertical or horizontal scrolling direction, finite / infinite loop carousel , with both 2D plane effect or 3D zoom effect' 5 | s.homepage = 'https://github.com/Chan4iOS/SCAdView' 6 | s.author = "CT4 => 284766710@qq.com" 7 | s.source = {:git => 'https://github.com/Chan4iOS/SCAdView.git', :tag => "#{s.version}"} 8 | s.source_files = "SCAdView/**/*.{h,m}" 9 | s.requires_arc = true 10 | s.libraries = 'z' 11 | s.ios.deployment_target = '8.0' 12 | s.license = 'MIT' 13 | s.frameworks = 'UIKit' 14 | end 15 | -------------------------------------------------------------------------------- /SCAdView/SCAdCollectionViewLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdCollectionViewLayout.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | @protocol SCCollectionViewFlowLayoutDelegate 11 | 12 | -(void)sc_collectioViewScrollToIndex:(NSInteger)index; 13 | 14 | @end 15 | @interface SCAdCollectionViewLayout : UICollectionViewFlowLayout 16 | /** 17 | * 非当前广告的alpha值 18 | */ 19 | @property (nonatomic,assign) CGFloat secondaryItemMinAlpha; 20 | /** 21 | * 3D缩放值,若为0,则为2D广告 22 | */ 23 | @property (nonatomic,assign)CGFloat threeDimensionalScale; 24 | /** 25 | * 循环起始点 26 | */ 27 | @property (nonatomic,assign)NSInteger cycleIndex; 28 | /** 29 | * 代理 30 | */ 31 | @property (nonatomic,assign) iddelegate; 32 | @end 33 | -------------------------------------------------------------------------------- /SCAdView/SCAdCollectionViewLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdCollectionViewLayout.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCAdCollectionViewLayout.h" 10 | @implementation SCAdCollectionViewLayout 11 | { 12 | NSInteger _index; 13 | } 14 | 15 | // 初始化方法 16 | - (instancetype)init 17 | { 18 | if (self == [super init]) { 19 | _index = 0; 20 | } 21 | return self; 22 | } 23 | // 该方法会自动重载 24 | - (void)prepareLayout 25 | { 26 | [super prepareLayout]; 27 | } 28 | 29 | ////以下三个方法必须一起重载 分别是返回可见区域尺寸 获取可见区域内可见的item数组 当滚动的时候一直重绘collectionView 30 | #pragma mark 重载方法1 31 | // 返回可见区域的的内容尺寸 32 | - (CGSize)collectionViewContentSize 33 | { 34 | return [super collectionViewContentSize]; 35 | } 36 | 37 | #pragma mark 重载方法2 38 | // 返回rect中所有元素的布局属性 39 | // 返回的是包含UICollectionViewLayoutAttributes的NSArray 40 | // UICollectionViewAttributes可以是cell,追加视图以及装饰视图的信息,通过以下三个不同的方法可以获取到不同类型的UICollectionViewLayoutAttributes属性 41 | // layoutAttributesForCellWithIndexPath: 返回对应cell的UICollectionViewAttributes布局属性 42 | // layoutAtttibutesForSupplementaryViewOfKind:withIndexPath: 返回装饰的布局属性 如果没有追加视图可不重载 43 | // layoutAttributesForDecorationViewOfKind:withIndexPath: 返回装饰的布局属性 如果没有可以不重载 44 | - (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect 45 | { 46 | // //1. 获取可见区域 47 | CGRect visibleRect; 48 | if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 49 | visibleRect= CGRectMake(self.collectionView.contentOffset.x, 0, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); 50 | }else{ 51 | visibleRect = CGRectMake(0,self.collectionView.contentOffset.y, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); 52 | } 53 | // //2. 获得这个区域的item 54 | NSArray *visibleItemArray =[[NSArray alloc] initWithArray:[super layoutAttributesForElementsInRect:visibleRect]copyItems:YES]; 55 | // NSArray *visibleItemArray =[[NSArray alloc] initWithArray: [super layoutAttributesForElementsInRect:rect] copyItems:YES]; 56 | //3. 遍历,让靠近中心线的item方法,离开的缩小 57 | NSInteger closest_index = 0; 58 | CGFloat distanceToCenter = 10000.0; 59 | CGFloat z_index = 0; 60 | for (UICollectionViewLayoutAttributes *attributes in visibleItemArray) 61 | { 62 | 63 | CGFloat scale = 0; 64 | CGFloat absOffset = 0; 65 | if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 66 | //1. 获取每个item距离可见区域左侧边框的距离 有正负 67 | CGFloat leftMargin = attributes.center.x - self.collectionView.contentOffset.x; 68 | //2. 获取边框距离屏幕中心的距离(固定的) 69 | CGFloat halfCenterX = self.collectionView.frame.size.width / 2; 70 | //3. 获取距离中心的的偏移量,需要绝对值 71 | absOffset = fabs(halfCenterX - leftMargin); 72 | //4. 获取的实际的缩放比例 距离中心越多,这个值就越小,也就是item的scale越小 中心是方法最大的 73 | scale = 1 - absOffset / halfCenterX; 74 | }else{ 75 | //1. 获取每个item距离可见区域左侧边框的距离 有正负 76 | CGFloat topMargin = attributes.center.y - self.collectionView.contentOffset.y; 77 | //2. 获取边框距离屏幕中心的距离(固定的) 78 | CGFloat halfCenterY = self.collectionView.frame.size.height / 2; 79 | //3. 获取距离中心的的偏移量,需要绝对值 80 | absOffset = fabs(halfCenterY - topMargin); 81 | //4. 获取的实际的缩放比例 距离中心越多,这个值就越小,也就是item的scale越小 中心是方法最大的 82 | scale = 1 - absOffset / halfCenterY; 83 | } 84 | 85 | //5. 缩放 86 | if (self.threeDimensionalScale>0) { 87 | attributes.transform3D = CATransform3DMakeScale(1 + scale * (self.threeDimensionalScale-1), 1 + scale * (self.threeDimensionalScale-1),1); 88 | } 89 | //6. 是否需要透明 90 | if (self.secondaryItemMinAlpha>0||self.secondaryItemMinAlpha<1) 91 | { 92 | if (scale < self.secondaryItemMinAlpha) 93 | { 94 | attributes.alpha = self.secondaryItemMinAlpha; 95 | } 96 | else if (scale > 0.99) 97 | { 98 | attributes.alpha = 1.0; 99 | } 100 | else 101 | { 102 | attributes.alpha = scale; 103 | } 104 | } 105 | //7.层次 : 比较取得最靠近中间的item,重置z-index 106 | if (absOffset0) { 119 | UICollectionViewLayoutAttributes *closest_attribute = visibleItemArray[closest_index]; 120 | closest_attribute.zIndex = 1000; 121 | } 122 | return visibleItemArray; 123 | } 124 | 125 | #pragma mark 重载方法3 126 | // 滚动的时候会一直调用 127 | // 当边界发生变化的时候,是否应该刷新布局。如果YES那么就是边界发生变化的时候,重新计算布局信息 这里的newBounds变化的只有偏移量的变化 128 | - (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds 129 | { 130 | // 把collectionView本身的中心位子(固定的),转换成collectionView整个内容上的point 131 | CGPoint pInView = [self.collectionView.superview convertPoint:self.collectionView.center toView:self.collectionView]; 132 | 133 | // 通过坐标获取对应的indexpath 134 | NSIndexPath *indexPathNow = [self.collectionView indexPathForItemAtPoint:pInView]; 135 | 136 | if (indexPathNow.row == 0) 137 | { 138 | if(self.scrollDirection == UICollectionViewScrollDirectionHorizontal){ 139 | if (newBounds.origin.x < SC_ScreenSize().width / 2) 140 | { 141 | if (_index != indexPathNow.row) 142 | { 143 | _index = 0; 144 | if (self.delegate && [self.delegate respondsToSelector:@selector(sc_collectioViewScrollToIndex:)]) 145 | { 146 | [self.delegate sc_collectioViewScrollToIndex:_index]; 147 | } 148 | 149 | } 150 | } 151 | }else{ 152 | if (newBounds.origin.y < SC_ScreenSize().height / 2) 153 | { 154 | if (_index != indexPathNow.row) 155 | { 156 | _index = 0; 157 | if (self.delegate && [self.delegate respondsToSelector:@selector(sc_collectioViewScrollToIndex:)]) 158 | { 159 | [self.delegate sc_collectioViewScrollToIndex:_index]; 160 | } 161 | 162 | } 163 | } 164 | } 165 | 166 | } 167 | else 168 | { 169 | // NSLog(@"%ld,%ld",_index,indexPathNow.row); 170 | if (_index != indexPathNow.row) 171 | { 172 | _index = indexPathNow.row; 173 | if (self.delegate && [self.delegate respondsToSelector:@selector(sc_collectioViewScrollToIndex:)]) 174 | { 175 | [self.delegate sc_collectioViewScrollToIndex:_index]; 176 | } 177 | } 178 | 179 | 180 | } 181 | 182 | 183 | [super shouldInvalidateLayoutForBoundsChange:newBounds]; 184 | return YES; 185 | } 186 | 187 | 188 | 189 | #pragma mark 指向item的中心 190 | // 该方法可写可不写,主要是让滚动的item根据距离中心的值,确定哪个必须展示在中心,不会像普通的那样滚动到哪里就停到哪里 191 | - (CGPoint)targetContentOffsetForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity 192 | { 193 | // ProposeContentOffset是本来应该停下的位子 194 | // 1. 先给一个字段存储最小的偏移量 那么默认就是无限大 195 | CGFloat minOffset = CGFLOAT_MAX; 196 | // 2. 获取到可见区域的centerX 和centerY 197 | CGFloat horizontalCenter = proposedContentOffset.x + self.collectionView.bounds.size.width / 2; 198 | CGFloat verticalCenter = proposedContentOffset.y+self.collectionView.bounds.size.height/2; 199 | // 3. 拿到可见区域的rect 200 | CGRect visibleRect; 201 | if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 202 | visibleRect= CGRectMake(proposedContentOffset.x, 0, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); 203 | }else{ 204 | visibleRect = CGRectMake(0,proposedContentOffset.y, self.collectionView.bounds.size.width, self.collectionView.bounds.size.height); 205 | } 206 | // 4. 获取到所有可见区域内的item数组 207 | NSArray *visibleAttributes = [super layoutAttributesForElementsInRect:visibleRect]; 208 | 209 | // 5. 遍历数组,找到距离中心最近偏移量是多少 可以是垂直偏移量也可以是水平偏移量 210 | for (UICollectionViewLayoutAttributes *atts in visibleAttributes) 211 | { 212 | if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 213 | // 可见区域内每个item对应的中心X坐标 214 | CGFloat itemCenterX = atts.center.x; 215 | // 比较是否有更小的,有的话赋值给minOffset 216 | if (fabs(itemCenterX - horizontalCenter) <= fabs(minOffset)) { 217 | minOffset = itemCenterX - horizontalCenter; 218 | } 219 | }else{ 220 | // 可见区域内每个item对应的中心X坐标 221 | CGFloat itemCenterY = atts.center.y; 222 | // 比较是否有更小的,有的话赋值给minOffset 223 | if (fabs(itemCenterY - verticalCenter) <= fabs(minOffset)) { 224 | minOffset = itemCenterY - verticalCenter; 225 | } 226 | } 227 | 228 | 229 | 230 | } 231 | // 这里需要注意的是 eg水平方向为例: 上面获取到的minOffset有可能是负数,那么代表左边的item还没到中心,如果确定这种情况下左边的item是距离最近的,那么需要左边的item居中,意思就是collectionView的偏移量需要比原本更小才是,例如原先是1000的偏移,但是需要展示前一个item,所以需要1000减去某个偏移量,因此不需要更改偏移的正负 232 | 233 | // eg水平方向为例 :但是当propose小于0的时候或者大于contentSize(除掉左侧和右侧偏移以及单个cell宽度) 、 234 | // eg水平方向为例 : 防止当第一个或者最后一个的时候不会有居中(偏移量超过了本身的宽度),直接卡在推荐的停留位置 235 | if (self.scrollDirection == UICollectionViewScrollDirectionHorizontal) { 236 | CGFloat centerOffsetX = proposedContentOffset.x + minOffset; 237 | if (centerOffsetX < 0) { 238 | centerOffsetX = 0; 239 | } 240 | 241 | if (centerOffsetX > self.collectionView.contentSize.width -(self.sectionInset.left + self.sectionInset.right + self.itemSize.width)) { 242 | centerOffsetX = floor(centerOffsetX); 243 | } 244 | return CGPointMake(centerOffsetX, proposedContentOffset.y); 245 | }else{ 246 | CGFloat centerOffsetY = proposedContentOffset.y + minOffset; 247 | if (centerOffsetY < 0) { 248 | centerOffsetY = 0; 249 | } 250 | 251 | if (centerOffsetY > self.collectionView.contentSize.height -(self.sectionInset.top + self.sectionInset.bottom + self.itemSize.height)) { 252 | centerOffsetY = floor(centerOffsetY); 253 | } 254 | return CGPointMake(proposedContentOffset.x, centerOffsetY); 255 | } 256 | } 257 | 258 | 259 | CGSize SC_ScreenSize() { 260 | static CGSize size; 261 | static dispatch_once_t onceToken; 262 | dispatch_once(&onceToken, ^{ 263 | size = [UIScreen mainScreen].bounds.size; 264 | if (size.height < size.width) { 265 | CGFloat tmp = size.height; 266 | size.height = size.width; 267 | size.width = tmp; 268 | } 269 | }); 270 | return size; 271 | } 272 | 273 | -(void)setCycleIndex:(NSInteger)cycleIndex{ 274 | _cycleIndex = cycleIndex; 275 | _index=cycleIndex; 276 | } 277 | 278 | @end 279 | -------------------------------------------------------------------------------- /SCAdView/SCAdView.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdView.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SCAdViewRenderDelegate.h" 11 | 12 | ///将builder的LINE_SPACING设置为该值则会自动计算合适的间距 13 | #define SC_BUILDER_LINE_SPACING_AUTO -10001 14 | typedef NS_ENUM(NSInteger,SCAdViewScrollDirection) { 15 | SCAdViewScrollDirectionRight = 0,//轮播向右 16 | SCAdViewScrollDirectionLeft,//轮播向左 17 | SCAdViewScrollDirectionBotom,//轮播向下 18 | SCAdViewScrollDirectionTop,//轮播向上 19 | }; 20 | @interface SCAdViewBuilder : NSObject 21 | #pragma mark -必要参数 22 | /** 23 | * 必填:广告模型数组 24 | */ 25 | @property (nonatomic,strong)NSArray *adArray; 26 | /** 27 | * view frame 28 | */ 29 | @property (nonatomic,assign)CGRect viewFrame; 30 | /** 31 | * 广告的大小 advertisement's item size 32 | */ 33 | @property (nonatomic,assign)CGSize adItemSize; 34 | /** 35 | * 最小行间距 36 | */ 37 | @property (nonatomic,assign)CGFloat minimumLineSpacing; 38 | /** 39 | * 非当前广告的alpha值 如果不需要,填负数 40 | */ 41 | @property (nonatomic,assign) CGFloat secondaryItemMinAlpha; 42 | /** 43 | * adItem 的 nib (与class只能二选一) 44 | */ 45 | @property (nonatomic,strong)NSString *itemCellNibName; 46 | /** 47 | * adItem 的 Class (与nil 只能二选一) 48 | */ 49 | @property (nonatomic,strong)NSString *itemCellClassName; 50 | /** 51 | * 是否允许拖拽 52 | */ 53 | @property (nonatomic,assign)BOOL scrollEnabled; 54 | 55 | #pragma mark -非必要参数,有默认值 56 | /** 57 | * 无限轮播间隔 58 | */ 59 | @property (nonatomic,assign)NSTimeInterval infiniteCycle; 60 | /** 61 | * scroll direction 轮播的方向 默认为向右 62 | */ 63 | @property (nonatomic,assign)SCAdViewScrollDirection autoScrollDirection; 64 | /** 65 | * 最小item间距 66 | */ 67 | @property (nonatomic,assign)CGFloat minimumInteritemSpacing; 68 | /** 69 | * 3D缩放值,若为0,则为2D广告 3D scale if threeDimensionalScale<0,it will use 2D 70 | */ 71 | @property (nonatomic,assign)CGFloat threeDimensionalScale; 72 | /** 73 | * 无限轮播 默认为yes Default is Yes 74 | */ 75 | @property (nonatomic,assign)BOOL allowedInfinite; 76 | 77 | @end 78 | 79 | @protocol SCAdViewRenderDelegate; 80 | 81 | @protocol SCAdViewDelegate 82 | /** 83 | * @brief 滑动到的广告的index 84 | */ 85 | -(void)sc_scrollToIndex:(NSInteger)index; 86 | /** 87 | * @brief 点击了广告,返回广告信息 88 | */ 89 | -(void)sc_didClickAd:(id)adModel; 90 | 91 | @end 92 | 93 | @interface SCAdView : UIView 94 | @property (nonatomic,weak)iddelegate; 95 | /** 96 | * @brief 构造方法 97 | * @param builderBlock 通过在block中配置builder中的参数来实现对广告view的不同设置 98 | * @return SCAdView 99 | */ 100 | -(instancetype)initWithBuilder:(void (^) (SCAdViewBuilder *builder))builderBlock; 101 | /** 102 | * @brief 开始播放 103 | */ 104 | -(void)play; 105 | /** 106 | * @brief 停止播放 107 | */ 108 | -(void)pause; 109 | /** 110 | * @brief 刷新内容 111 | * @param adArray 内容数组 112 | */ 113 | -(void)reloadWithDataArray:(NSArray *)adArray; 114 | @end 115 | -------------------------------------------------------------------------------- /SCAdView/SCAdView.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdView.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCAdView.h" 10 | #import "SCAdCollectionViewLayout.h" 11 | 12 | ///默认的自动轮播的时间间隔 13 | #define SC_BUILDER_DEFAULT_AUTO_SCROLL_CYCLE 3.0 14 | ///2D时自动计算linespacing的倍数 15 | #define SC_BUILDER_AUTO_SET_LINESPACING_RATIO 0.15 16 | ///不使用3D缩放 >0起效 17 | #define SC_BUILDER_NO_3D -1 18 | ///最小的行间距 如果不足够大,会出现两行的情况 19 | #define SC_BUILDER_DEFAULT_MINIMUMINTERITEMSPACING 10000 20 | 21 | #define SC_AD_CELL_IDENTIFIER @"SC_AD_CELL_IDENTIFIER" 22 | #define SC_ERROR(_DESC_) NSCAssert(0,_DESC_) 23 | ///轮播两侧准备的item倍数 count of prepared item group at the both side 24 | #define SC_PREPARE_ITEM_TIME 2 25 | @interface SCAdView() 26 | { 27 | SCAdViewBuilder *_builder; 28 | ///因为当用户滑动的时候,轮播不应该继续,所以会被停掉,但是当滑动结束,会根据是否开启了轮播而重新开启 29 | BOOL _isPlaying; //真实是否开启了播放的状态 30 | BOOL _expctedToPlay;//用户启动的play 31 | SCAdCollectionViewLayout *_layout; 32 | } 33 | /** 34 | * 计时器 35 | */ 36 | @property (nonatomic,strong)NSTimer *timer; 37 | @end 38 | 39 | @implementation SCAdViewBuilder 40 | @end 41 | 42 | @interface SCAdView() 43 | /** 44 | * collection 45 | */ 46 | @property (nonatomic,strong)UICollectionView *collectionView; 47 | /** 48 | * data 49 | */ 50 | @property (nonatomic,strong)NSMutableArray *dataArray; 51 | @end 52 | 53 | @implementation SCAdView 54 | 55 | -(instancetype)initWithBuilder:(void (^) (SCAdViewBuilder *builder))builderBlock{ 56 | if (self = [super init]) { 57 | SCAdViewBuilder *builder = [SCAdViewBuilder new]; 58 | builder.allowedInfinite = YES; 59 | builder.scrollEnabled = YES; 60 | builder.infiniteCycle = SC_BUILDER_DEFAULT_AUTO_SCROLL_CYCLE; 61 | builder.threeDimensionalScale = SC_BUILDER_NO_3D; 62 | builder.minimumInteritemSpacing = SC_BUILDER_DEFAULT_MINIMUMINTERITEMSPACING; 63 | builder.minimumLineSpacing = SC_BUILDER_LINE_SPACING_AUTO; 64 | if (builderBlock) { 65 | builderBlock(builder); 66 | } 67 | [self _auto_set_builder:builder]; 68 | [self setUpWithBuilder:builder]; 69 | } 70 | return self; 71 | } 72 | 73 | -(void)_auto_set_builder:(SCAdViewBuilder *)builder{ 74 | //自动填充lineSpacing 75 | if (builder.minimumLineSpacing==SC_BUILDER_LINE_SPACING_AUTO) { 76 | if (builder.threeDimensionalScale>1) { 77 | if (builder.autoScrollDirection>1) {//用户漏了填写间距,将自动填写 78 | builder.minimumLineSpacing = (builder.threeDimensionalScale-1)*builder.adItemSize.height/1; 79 | }else{ 80 | builder.minimumLineSpacing = (builder.threeDimensionalScale-1)*builder.adItemSize.width/1; 81 | } 82 | }else if(builder.threeDimensionalScale<0){ 83 | if (builder.autoScrollDirection>1) {//用户漏了填写间距,将自动填写 84 | builder.minimumLineSpacing = SC_BUILDER_AUTO_SET_LINESPACING_RATIO*builder.adItemSize.height/1; 85 | }else{ 86 | builder.minimumLineSpacing = SC_BUILDER_AUTO_SET_LINESPACING_RATIO*builder.adItemSize.width/1; 87 | } 88 | } 89 | } 90 | } 91 | /** 92 | * @brief 初始化 93 | */ 94 | -(void)setUpWithBuilder:(SCAdViewBuilder *)builder{ 95 | _builder = builder; 96 | self.frame = builder.viewFrame; 97 | NSArray *dataArray = @[]; 98 | if (!builder.allowedInfinite) { 99 | if (builder.adArray) { 100 | self.dataArray = [NSMutableArray arrayWithArray:builder.adArray]; 101 | } 102 | }else{//无限轮播 103 | if (builder.adArray && builder.adArray.count>0) { 104 | for (int i=0;i<2*SC_PREPARE_ITEM_TIME+1;i++) { 105 | dataArray = [dataArray arrayByAddingObjectsFromArray:builder.adArray]; 106 | } 107 | } 108 | self.dataArray = [NSMutableArray arrayWithArray:dataArray]; 109 | } 110 | SCAdCollectionViewLayout *layout = [SCAdCollectionViewLayout new]; 111 | layout.scrollDirection = (_builder.autoScrollDirection>1)?UICollectionViewScrollDirectionVertical:UICollectionViewScrollDirectionHorizontal; 112 | layout.itemSize = builder.adItemSize; 113 | layout.minimumLineSpacing = builder.minimumLineSpacing; 114 | layout.minimumInteritemSpacing = builder.minimumInteritemSpacing; 115 | layout.secondaryItemMinAlpha = builder.secondaryItemMinAlpha; 116 | layout.threeDimensionalScale = builder.threeDimensionalScale; 117 | layout.delegate = self; 118 | layout.cycleIndex = builder.allowedInfinite?_builder.adArray.count*SC_PREPARE_ITEM_TIME:-1; 119 | _layout = layout; 120 | if(_builder.autoScrollDirection>1){ 121 | CGFloat y_inset =(self.frame.size.height-layout.itemSize.height) / 2.f; 122 | layout.sectionInset = UIEdgeInsetsMake(y_inset,0,y_inset,0); 123 | }else{ 124 | CGFloat x_inset =(self.frame.size.width-layout.itemSize.width) / 2.f; 125 | layout.sectionInset = UIEdgeInsetsMake(0, x_inset, 0, x_inset); 126 | } 127 | self.collectionView = [[UICollectionView alloc]initWithFrame:(CGRect){0,0,self.frame.size} collectionViewLayout:layout]; 128 | self.collectionView.showsVerticalScrollIndicator = NO; 129 | self.collectionView.showsHorizontalScrollIndicator = NO; 130 | self.collectionView.delegate = self; 131 | self.collectionView.dataSource = self; 132 | self.collectionView.decelerationRate = 0; 133 | self.collectionView.scrollEnabled = builder.scrollEnabled; 134 | if (builder.itemCellNibName.length>0) { 135 | UINib *nib = [UINib nibWithNibName:builder.itemCellNibName bundle:nil]; 136 | [self.collectionView registerNib:nib forCellWithReuseIdentifier:SC_AD_CELL_IDENTIFIER]; 137 | }else if(builder.itemCellClassName.length>0 && NSClassFromString(builder.itemCellClassName)){ 138 | [self.collectionView registerClass:NSClassFromString(builder.itemCellClassName) forCellWithReuseIdentifier:SC_AD_CELL_IDENTIFIER]; 139 | }else{ 140 | SC_ERROR(@"builder必须参数缺失 : ------>必须在builder指定一个cell的类或者nib"); 141 | } 142 | [self addSubview:self.collectionView]; 143 | } 144 | 145 | -(void)layoutSubviews{ 146 | [super layoutSubviews]; 147 | if(_builder.allowedInfinite){ 148 | CGPoint offet; 149 | if (_builder.autoScrollDirection<=1) { 150 | offet = (CGPoint){(_builder.adItemSize.width+_builder.minimumLineSpacing)*(_builder.adArray.count)*SC_PREPARE_ITEM_TIME,0}; 151 | }else{ 152 | offet = (CGPoint){0,(_builder.adItemSize.height+_builder.minimumLineSpacing)*(_builder.adArray.count)*SC_PREPARE_ITEM_TIME}; 153 | } 154 | 155 | [self.collectionView setContentOffset:offet]; 156 | } 157 | } 158 | /** 159 | * @brief 计时器执行方法,增加偏移量 160 | */ 161 | -(void)_playNextAd{ 162 | CGPoint pInUnderView = [self convertPoint:self.collectionView.center toView:self.collectionView]; 163 | // 获取中间的indexpath 164 | NSIndexPath *indexpath = [self.collectionView indexPathForItemAtPoint:pInUnderView]; 165 | // 获取滑动目标的indexPath 166 | NSIndexPath *to_indexPath; 167 | if(_builder.autoScrollDirection==SCAdViewScrollDirectionRight || _builder.autoScrollDirection==SCAdViewScrollDirectionBotom){ 168 | to_indexPath=[NSIndexPath indexPathForRow:indexpath.row+1 inSection:0];//向右或向下 169 | }else{ 170 | to_indexPath=[NSIndexPath indexPathForRow:indexpath.row-1 inSection:0];//向左或向上 171 | } 172 | if (_builder.autoScrollDirection>1) { 173 | [self.collectionView scrollToItemAtIndexPath:to_indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:YES]; 174 | }else{ 175 | [self.collectionView scrollToItemAtIndexPath:to_indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; 176 | } 177 | } 178 | #pragma mark -collection delegate/datasource 179 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView 180 | { 181 | return 1; 182 | } 183 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section 184 | { 185 | return self.dataArray.count; 186 | } 187 | 188 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 189 | { 190 | id model = self.dataArray[indexPath.item]; 191 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:SC_AD_CELL_IDENTIFIER forIndexPath:indexPath]; 192 | [cell setModel:model]; 193 | return cell; 194 | } 195 | 196 | // 点击item的时候 197 | - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 198 | { 199 | CGPoint pInUnderView = [self convertPoint:collectionView.center toView:collectionView]; 200 | 201 | // 获取中间的indexpath 202 | NSIndexPath *indexpathNew = [collectionView indexPathForItemAtPoint:pInUnderView]; 203 | NSLog(@"%ld",indexpathNew.row); 204 | if (indexPath.row == indexpathNew.row) 205 | { 206 | //点击了中间的广告 207 | if (self.delegate &&[self.delegate respondsToSelector:@selector(sc_didClickAd:)]) { 208 | [self.delegate sc_didClickAd:self.dataArray[indexPath.row]]; 209 | } 210 | } 211 | else 212 | { 213 | if (_builder.autoScrollDirection<1) { 214 | //点击了背后的广告,将会被移动上来 215 | [self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES]; 216 | }else{ 217 | [self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:YES]; 218 | } 219 | 220 | } 221 | } 222 | -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ 223 | [self _secretlyChangeIndex]; 224 | if (_expctedToPlay) { 225 | [self play]; 226 | } 227 | } 228 | -(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{ 229 | [self _secretlyChangeIndex]; 230 | } 231 | -(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ 232 | if (_expctedToPlay) { 233 | [self _pauseOperation]; 234 | } 235 | } 236 | 237 | -(void)_secretlyChangeIndex{ 238 | if (!_builder.allowedInfinite)return; 239 | CGPoint pInUnderView = [self convertPoint:self.collectionView.center toView:self.collectionView]; 240 | // 获取中间的indexpath 241 | NSIndexPath *indexpath = [self.collectionView indexPathForItemAtPoint:pInUnderView]; 242 | NSInteger itemCount =_builder.adArray.count; 243 | if (indexpath.row=itemCount*(SC_PREPARE_ITEM_TIME+1)) { 244 | NSIndexPath *to_indexPath =[NSIndexPath indexPathForRow:indexpath.row%itemCount+itemCount*SC_PREPARE_ITEM_TIME inSection:0]; 245 | if (_builder.autoScrollDirection>1) { 246 | [self.collectionView scrollToItemAtIndexPath:to_indexPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO]; 247 | }else{ 248 | [self.collectionView scrollToItemAtIndexPath:to_indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:NO]; 249 | } 250 | } 251 | } 252 | 253 | 254 | #pragma mark -layout delegate 255 | -(void)sc_collectioViewScrollToIndex:(NSInteger)index{ 256 | if (self.delegate &&[self.delegate respondsToSelector:@selector(sc_scrollToIndex:)]) { 257 | [self.delegate sc_scrollToIndex:index%_builder.adArray.count]; 258 | } 259 | } 260 | 261 | #pragma mark -override 262 | -(void)setBackgroundColor:(UIColor *)backgroundColor{ 263 | [super setBackgroundColor:backgroundColor]; 264 | [self.collectionView setBackgroundColor:backgroundColor]; 265 | } 266 | 267 | 268 | #pragma mark operate 269 | -(void)play{ 270 | if (_builder.allowedInfinite) { 271 | [self _pauseOperation]; 272 | _expctedToPlay = YES; 273 | _isPlaying = YES; 274 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 275 | if(!self.timer){ 276 | self.timer =[NSTimer scheduledTimerWithTimeInterval:_builder.infiniteCycle target:self selector:@selector(_playNextAd) userInfo:nil repeats:YES]; 277 | } 278 | }); 279 | }else{ 280 | SC_ERROR(@"builder没有允许无限轮播"); 281 | } 282 | 283 | } 284 | -(void)pause{ 285 | _expctedToPlay = NO; 286 | [self _pauseOperation]; 287 | } 288 | -(void)_pauseOperation{ 289 | _isPlaying = NO; 290 | if (_builder.allowedInfinite) { 291 | if (self.timer) { 292 | [self.timer invalidate]; 293 | } 294 | self.timer = nil; 295 | } 296 | } 297 | -(void)reloadWithDataArray:(NSArray *)adArray{ 298 | NSArray *dataArray = @[]; 299 | if (!_builder.allowedInfinite) { 300 | if (adArray) { 301 | self.dataArray = [NSMutableArray arrayWithArray:adArray]; 302 | } 303 | }else{//无限轮播 304 | if (adArray && adArray.count>0) { 305 | for (int i=0;i<2*SC_PREPARE_ITEM_TIME+1;i++) { 306 | dataArray = [dataArray arrayByAddingObjectsFromArray:adArray]; 307 | } 308 | } 309 | self.dataArray = [NSMutableArray arrayWithArray:dataArray]; 310 | } 311 | _builder.adArray = adArray; 312 | _layout.cycleIndex =_builder.allowedInfinite?_builder.adArray.count*SC_PREPARE_ITEM_TIME:-1; 313 | [self.collectionView reloadData]; 314 | [self _secretlyChangeIndex]; 315 | } 316 | @end 317 | -------------------------------------------------------------------------------- /SCAdView/SCAdViewRenderDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdViewRenderDelegate.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @protocol SCAdViewRenderDelegate 12 | @required 13 | /** 14 | * @brief 通过实现此代理为view或者cell来设置 15 | */ 16 | -(void)setModel:(id)model; 17 | @end 18 | -------------------------------------------------------------------------------- /SCAdViewDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0BD19C7E1F669BB40056B278 /* SCAdCollectionViewLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BD19C7A1F669BB40056B278 /* SCAdCollectionViewLayout.m */; }; 11 | 0BD19C7F1F669BB40056B278 /* SCAdView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BD19C7C1F669BB40056B278 /* SCAdView.m */; }; 12 | 64EC7E3C1E49735C003D1BA0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E3B1E49735C003D1BA0 /* main.m */; }; 13 | 64EC7E3F1E49735C003D1BA0 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E3E1E49735C003D1BA0 /* AppDelegate.m */; }; 14 | 64EC7E421E49735C003D1BA0 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E411E49735C003D1BA0 /* ViewController.m */; }; 15 | 64EC7E451E49735C003D1BA0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64EC7E431E49735C003D1BA0 /* Main.storyboard */; }; 16 | 64EC7E471E49735C003D1BA0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 64EC7E461E49735C003D1BA0 /* Assets.xcassets */; }; 17 | 64EC7E4A1E49735C003D1BA0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 64EC7E481E49735C003D1BA0 /* LaunchScreen.storyboard */; }; 18 | 64EC7E551E49735C003D1BA0 /* SCAdViewDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E541E49735C003D1BA0 /* SCAdViewDemoTests.m */; }; 19 | 64EC7E601E49735C003D1BA0 /* SCAdViewDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E5F1E49735C003D1BA0 /* SCAdViewDemoUITests.m */; }; 20 | 64EC7E7C1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E7A1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.m */; }; 21 | 64EC7E7D1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 64EC7E7B1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.xib */; }; 22 | 64EC7E811E4B1516003D1BA0 /* HeroModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 64EC7E801E4B1516003D1BA0 /* HeroModel.m */; }; 23 | /* End PBXBuildFile section */ 24 | 25 | /* Begin PBXContainerItemProxy section */ 26 | 64EC7E511E49735C003D1BA0 /* PBXContainerItemProxy */ = { 27 | isa = PBXContainerItemProxy; 28 | containerPortal = 64EC7E2F1E49735C003D1BA0 /* Project object */; 29 | proxyType = 1; 30 | remoteGlobalIDString = 64EC7E361E49735C003D1BA0; 31 | remoteInfo = SCAdViewDemo; 32 | }; 33 | 64EC7E5C1E49735C003D1BA0 /* PBXContainerItemProxy */ = { 34 | isa = PBXContainerItemProxy; 35 | containerPortal = 64EC7E2F1E49735C003D1BA0 /* Project object */; 36 | proxyType = 1; 37 | remoteGlobalIDString = 64EC7E361E49735C003D1BA0; 38 | remoteInfo = SCAdViewDemo; 39 | }; 40 | /* End PBXContainerItemProxy section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 0BD19C791F669BB40056B278 /* SCAdCollectionViewLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAdCollectionViewLayout.h; sourceTree = ""; }; 44 | 0BD19C7A1F669BB40056B278 /* SCAdCollectionViewLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAdCollectionViewLayout.m; sourceTree = ""; }; 45 | 0BD19C7B1F669BB40056B278 /* SCAdView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAdView.h; sourceTree = ""; }; 46 | 0BD19C7C1F669BB40056B278 /* SCAdView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAdView.m; sourceTree = ""; }; 47 | 0BD19C7D1F669BB40056B278 /* SCAdViewRenderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAdViewRenderDelegate.h; sourceTree = ""; }; 48 | 64EC7E371E49735C003D1BA0 /* SCAdViewDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SCAdViewDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 49 | 64EC7E3B1E49735C003D1BA0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 50 | 64EC7E3D1E49735C003D1BA0 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 51 | 64EC7E3E1E49735C003D1BA0 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 52 | 64EC7E401E49735C003D1BA0 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 53 | 64EC7E411E49735C003D1BA0 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 54 | 64EC7E441E49735C003D1BA0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 55 | 64EC7E461E49735C003D1BA0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 56 | 64EC7E491E49735C003D1BA0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 57 | 64EC7E4B1E49735C003D1BA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 58 | 64EC7E501E49735C003D1BA0 /* SCAdViewDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCAdViewDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 59 | 64EC7E541E49735C003D1BA0 /* SCAdViewDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SCAdViewDemoTests.m; sourceTree = ""; }; 60 | 64EC7E561E49735C003D1BA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | 64EC7E5B1E49735C003D1BA0 /* SCAdViewDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SCAdViewDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 62 | 64EC7E5F1E49735C003D1BA0 /* SCAdViewDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SCAdViewDemoUITests.m; sourceTree = ""; }; 63 | 64EC7E611E49735C003D1BA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 64EC7E791E49823D003D1BA0 /* SCAdDemoCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAdDemoCollectionViewCell.h; sourceTree = ""; }; 65 | 64EC7E7A1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAdDemoCollectionViewCell.m; sourceTree = ""; }; 66 | 64EC7E7B1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SCAdDemoCollectionViewCell.xib; sourceTree = ""; }; 67 | 64EC7E7F1E4B1516003D1BA0 /* HeroModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeroModel.h; sourceTree = ""; }; 68 | 64EC7E801E4B1516003D1BA0 /* HeroModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HeroModel.m; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | 64EC7E341E49735C003D1BA0 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | ); 77 | runOnlyForDeploymentPostprocessing = 0; 78 | }; 79 | 64EC7E4D1E49735C003D1BA0 /* Frameworks */ = { 80 | isa = PBXFrameworksBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | ); 84 | runOnlyForDeploymentPostprocessing = 0; 85 | }; 86 | 64EC7E581E49735C003D1BA0 /* Frameworks */ = { 87 | isa = PBXFrameworksBuildPhase; 88 | buildActionMask = 2147483647; 89 | files = ( 90 | ); 91 | runOnlyForDeploymentPostprocessing = 0; 92 | }; 93 | /* End PBXFrameworksBuildPhase section */ 94 | 95 | /* Begin PBXGroup section */ 96 | 0BD19C781F669BB40056B278 /* SCAdView */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 0BD19C791F669BB40056B278 /* SCAdCollectionViewLayout.h */, 100 | 0BD19C7A1F669BB40056B278 /* SCAdCollectionViewLayout.m */, 101 | 0BD19C7B1F669BB40056B278 /* SCAdView.h */, 102 | 0BD19C7C1F669BB40056B278 /* SCAdView.m */, 103 | 0BD19C7D1F669BB40056B278 /* SCAdViewRenderDelegate.h */, 104 | ); 105 | path = SCAdView; 106 | sourceTree = SOURCE_ROOT; 107 | }; 108 | 64EC7E2E1E49735C003D1BA0 = { 109 | isa = PBXGroup; 110 | children = ( 111 | 64EC7E391E49735C003D1BA0 /* SCAdViewDemo */, 112 | 64EC7E531E49735C003D1BA0 /* SCAdViewDemoTests */, 113 | 64EC7E5E1E49735C003D1BA0 /* SCAdViewDemoUITests */, 114 | 64EC7E381E49735C003D1BA0 /* Products */, 115 | ); 116 | sourceTree = ""; 117 | }; 118 | 64EC7E381E49735C003D1BA0 /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 64EC7E371E49735C003D1BA0 /* SCAdViewDemo.app */, 122 | 64EC7E501E49735C003D1BA0 /* SCAdViewDemoTests.xctest */, 123 | 64EC7E5B1E49735C003D1BA0 /* SCAdViewDemoUITests.xctest */, 124 | ); 125 | name = Products; 126 | sourceTree = ""; 127 | }; 128 | 64EC7E391E49735C003D1BA0 /* SCAdViewDemo */ = { 129 | isa = PBXGroup; 130 | children = ( 131 | 0BD19C781F669BB40056B278 /* SCAdView */, 132 | 64EC7E791E49823D003D1BA0 /* SCAdDemoCollectionViewCell.h */, 133 | 64EC7E7A1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.m */, 134 | 64EC7E7B1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.xib */, 135 | 64EC7E7F1E4B1516003D1BA0 /* HeroModel.h */, 136 | 64EC7E801E4B1516003D1BA0 /* HeroModel.m */, 137 | 64EC7E3D1E49735C003D1BA0 /* AppDelegate.h */, 138 | 64EC7E3E1E49735C003D1BA0 /* AppDelegate.m */, 139 | 64EC7E401E49735C003D1BA0 /* ViewController.h */, 140 | 64EC7E411E49735C003D1BA0 /* ViewController.m */, 141 | 64EC7E431E49735C003D1BA0 /* Main.storyboard */, 142 | 64EC7E461E49735C003D1BA0 /* Assets.xcassets */, 143 | 64EC7E481E49735C003D1BA0 /* LaunchScreen.storyboard */, 144 | 64EC7E4B1E49735C003D1BA0 /* Info.plist */, 145 | 64EC7E3A1E49735C003D1BA0 /* Supporting Files */, 146 | ); 147 | path = SCAdViewDemo; 148 | sourceTree = ""; 149 | }; 150 | 64EC7E3A1E49735C003D1BA0 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 64EC7E3B1E49735C003D1BA0 /* main.m */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | 64EC7E531E49735C003D1BA0 /* SCAdViewDemoTests */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 64EC7E541E49735C003D1BA0 /* SCAdViewDemoTests.m */, 162 | 64EC7E561E49735C003D1BA0 /* Info.plist */, 163 | ); 164 | path = SCAdViewDemoTests; 165 | sourceTree = ""; 166 | }; 167 | 64EC7E5E1E49735C003D1BA0 /* SCAdViewDemoUITests */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 64EC7E5F1E49735C003D1BA0 /* SCAdViewDemoUITests.m */, 171 | 64EC7E611E49735C003D1BA0 /* Info.plist */, 172 | ); 173 | path = SCAdViewDemoUITests; 174 | sourceTree = ""; 175 | }; 176 | /* End PBXGroup section */ 177 | 178 | /* Begin PBXNativeTarget section */ 179 | 64EC7E361E49735C003D1BA0 /* SCAdViewDemo */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 64EC7E641E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemo" */; 182 | buildPhases = ( 183 | 64EC7E331E49735C003D1BA0 /* Sources */, 184 | 64EC7E341E49735C003D1BA0 /* Frameworks */, 185 | 64EC7E351E49735C003D1BA0 /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | ); 191 | name = SCAdViewDemo; 192 | productName = SCAdViewDemo; 193 | productReference = 64EC7E371E49735C003D1BA0 /* SCAdViewDemo.app */; 194 | productType = "com.apple.product-type.application"; 195 | }; 196 | 64EC7E4F1E49735C003D1BA0 /* SCAdViewDemoTests */ = { 197 | isa = PBXNativeTarget; 198 | buildConfigurationList = 64EC7E671E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemoTests" */; 199 | buildPhases = ( 200 | 64EC7E4C1E49735C003D1BA0 /* Sources */, 201 | 64EC7E4D1E49735C003D1BA0 /* Frameworks */, 202 | 64EC7E4E1E49735C003D1BA0 /* Resources */, 203 | ); 204 | buildRules = ( 205 | ); 206 | dependencies = ( 207 | 64EC7E521E49735C003D1BA0 /* PBXTargetDependency */, 208 | ); 209 | name = SCAdViewDemoTests; 210 | productName = SCAdViewDemoTests; 211 | productReference = 64EC7E501E49735C003D1BA0 /* SCAdViewDemoTests.xctest */; 212 | productType = "com.apple.product-type.bundle.unit-test"; 213 | }; 214 | 64EC7E5A1E49735C003D1BA0 /* SCAdViewDemoUITests */ = { 215 | isa = PBXNativeTarget; 216 | buildConfigurationList = 64EC7E6A1E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemoUITests" */; 217 | buildPhases = ( 218 | 64EC7E571E49735C003D1BA0 /* Sources */, 219 | 64EC7E581E49735C003D1BA0 /* Frameworks */, 220 | 64EC7E591E49735C003D1BA0 /* Resources */, 221 | ); 222 | buildRules = ( 223 | ); 224 | dependencies = ( 225 | 64EC7E5D1E49735C003D1BA0 /* PBXTargetDependency */, 226 | ); 227 | name = SCAdViewDemoUITests; 228 | productName = SCAdViewDemoUITests; 229 | productReference = 64EC7E5B1E49735C003D1BA0 /* SCAdViewDemoUITests.xctest */; 230 | productType = "com.apple.product-type.bundle.ui-testing"; 231 | }; 232 | /* End PBXNativeTarget section */ 233 | 234 | /* Begin PBXProject section */ 235 | 64EC7E2F1E49735C003D1BA0 /* Project object */ = { 236 | isa = PBXProject; 237 | attributes = { 238 | LastUpgradeCheck = 0820; 239 | ORGANIZATIONNAME = "Coder Chan"; 240 | TargetAttributes = { 241 | 64EC7E361E49735C003D1BA0 = { 242 | CreatedOnToolsVersion = 8.2.1; 243 | ProvisioningStyle = Automatic; 244 | }; 245 | 64EC7E4F1E49735C003D1BA0 = { 246 | CreatedOnToolsVersion = 8.2.1; 247 | ProvisioningStyle = Automatic; 248 | TestTargetID = 64EC7E361E49735C003D1BA0; 249 | }; 250 | 64EC7E5A1E49735C003D1BA0 = { 251 | CreatedOnToolsVersion = 8.2.1; 252 | ProvisioningStyle = Automatic; 253 | TestTargetID = 64EC7E361E49735C003D1BA0; 254 | }; 255 | }; 256 | }; 257 | buildConfigurationList = 64EC7E321E49735C003D1BA0 /* Build configuration list for PBXProject "SCAdViewDemo" */; 258 | compatibilityVersion = "Xcode 3.2"; 259 | developmentRegion = English; 260 | hasScannedForEncodings = 0; 261 | knownRegions = ( 262 | en, 263 | Base, 264 | ); 265 | mainGroup = 64EC7E2E1E49735C003D1BA0; 266 | productRefGroup = 64EC7E381E49735C003D1BA0 /* Products */; 267 | projectDirPath = ""; 268 | projectRoot = ""; 269 | targets = ( 270 | 64EC7E361E49735C003D1BA0 /* SCAdViewDemo */, 271 | 64EC7E4F1E49735C003D1BA0 /* SCAdViewDemoTests */, 272 | 64EC7E5A1E49735C003D1BA0 /* SCAdViewDemoUITests */, 273 | ); 274 | }; 275 | /* End PBXProject section */ 276 | 277 | /* Begin PBXResourcesBuildPhase section */ 278 | 64EC7E351E49735C003D1BA0 /* Resources */ = { 279 | isa = PBXResourcesBuildPhase; 280 | buildActionMask = 2147483647; 281 | files = ( 282 | 64EC7E4A1E49735C003D1BA0 /* LaunchScreen.storyboard in Resources */, 283 | 64EC7E471E49735C003D1BA0 /* Assets.xcassets in Resources */, 284 | 64EC7E7D1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.xib in Resources */, 285 | 64EC7E451E49735C003D1BA0 /* Main.storyboard in Resources */, 286 | ); 287 | runOnlyForDeploymentPostprocessing = 0; 288 | }; 289 | 64EC7E4E1E49735C003D1BA0 /* Resources */ = { 290 | isa = PBXResourcesBuildPhase; 291 | buildActionMask = 2147483647; 292 | files = ( 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | 64EC7E591E49735C003D1BA0 /* Resources */ = { 297 | isa = PBXResourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | ); 301 | runOnlyForDeploymentPostprocessing = 0; 302 | }; 303 | /* End PBXResourcesBuildPhase section */ 304 | 305 | /* Begin PBXSourcesBuildPhase section */ 306 | 64EC7E331E49735C003D1BA0 /* Sources */ = { 307 | isa = PBXSourcesBuildPhase; 308 | buildActionMask = 2147483647; 309 | files = ( 310 | 0BD19C7F1F669BB40056B278 /* SCAdView.m in Sources */, 311 | 64EC7E421E49735C003D1BA0 /* ViewController.m in Sources */, 312 | 0BD19C7E1F669BB40056B278 /* SCAdCollectionViewLayout.m in Sources */, 313 | 64EC7E3F1E49735C003D1BA0 /* AppDelegate.m in Sources */, 314 | 64EC7E7C1E49823D003D1BA0 /* SCAdDemoCollectionViewCell.m in Sources */, 315 | 64EC7E3C1E49735C003D1BA0 /* main.m in Sources */, 316 | 64EC7E811E4B1516003D1BA0 /* HeroModel.m in Sources */, 317 | ); 318 | runOnlyForDeploymentPostprocessing = 0; 319 | }; 320 | 64EC7E4C1E49735C003D1BA0 /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | 64EC7E551E49735C003D1BA0 /* SCAdViewDemoTests.m in Sources */, 325 | ); 326 | runOnlyForDeploymentPostprocessing = 0; 327 | }; 328 | 64EC7E571E49735C003D1BA0 /* Sources */ = { 329 | isa = PBXSourcesBuildPhase; 330 | buildActionMask = 2147483647; 331 | files = ( 332 | 64EC7E601E49735C003D1BA0 /* SCAdViewDemoUITests.m in Sources */, 333 | ); 334 | runOnlyForDeploymentPostprocessing = 0; 335 | }; 336 | /* End PBXSourcesBuildPhase section */ 337 | 338 | /* Begin PBXTargetDependency section */ 339 | 64EC7E521E49735C003D1BA0 /* PBXTargetDependency */ = { 340 | isa = PBXTargetDependency; 341 | target = 64EC7E361E49735C003D1BA0 /* SCAdViewDemo */; 342 | targetProxy = 64EC7E511E49735C003D1BA0 /* PBXContainerItemProxy */; 343 | }; 344 | 64EC7E5D1E49735C003D1BA0 /* PBXTargetDependency */ = { 345 | isa = PBXTargetDependency; 346 | target = 64EC7E361E49735C003D1BA0 /* SCAdViewDemo */; 347 | targetProxy = 64EC7E5C1E49735C003D1BA0 /* PBXContainerItemProxy */; 348 | }; 349 | /* End PBXTargetDependency section */ 350 | 351 | /* Begin PBXVariantGroup section */ 352 | 64EC7E431E49735C003D1BA0 /* Main.storyboard */ = { 353 | isa = PBXVariantGroup; 354 | children = ( 355 | 64EC7E441E49735C003D1BA0 /* Base */, 356 | ); 357 | name = Main.storyboard; 358 | sourceTree = ""; 359 | }; 360 | 64EC7E481E49735C003D1BA0 /* LaunchScreen.storyboard */ = { 361 | isa = PBXVariantGroup; 362 | children = ( 363 | 64EC7E491E49735C003D1BA0 /* Base */, 364 | ); 365 | name = LaunchScreen.storyboard; 366 | sourceTree = ""; 367 | }; 368 | /* End PBXVariantGroup section */ 369 | 370 | /* Begin XCBuildConfiguration section */ 371 | 64EC7E621E49735C003D1BA0 /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | CLANG_ANALYZER_NONNULL = YES; 376 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_ENABLE_MODULES = YES; 379 | CLANG_ENABLE_OBJC_ARC = YES; 380 | CLANG_WARN_BOOL_CONVERSION = YES; 381 | CLANG_WARN_CONSTANT_CONVERSION = YES; 382 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 383 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INFINITE_RECURSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 393 | COPY_PHASE_STRIP = NO; 394 | DEBUG_INFORMATION_FORMAT = dwarf; 395 | ENABLE_STRICT_OBJC_MSGSEND = YES; 396 | ENABLE_TESTABILITY = YES; 397 | GCC_C_LANGUAGE_STANDARD = gnu99; 398 | GCC_DYNAMIC_NO_PIC = NO; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_OPTIMIZATION_LEVEL = 0; 401 | GCC_PREPROCESSOR_DEFINITIONS = ( 402 | "DEBUG=1", 403 | "$(inherited)", 404 | ); 405 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 407 | GCC_WARN_UNDECLARED_SELECTOR = YES; 408 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 409 | GCC_WARN_UNUSED_FUNCTION = YES; 410 | GCC_WARN_UNUSED_VARIABLE = YES; 411 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 412 | MTL_ENABLE_DEBUG_INFO = YES; 413 | ONLY_ACTIVE_ARCH = YES; 414 | SDKROOT = iphoneos; 415 | }; 416 | name = Debug; 417 | }; 418 | 64EC7E631E49735C003D1BA0 /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | ALWAYS_SEARCH_USER_PATHS = NO; 422 | CLANG_ANALYZER_NONNULL = YES; 423 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 424 | CLANG_CXX_LIBRARY = "libc++"; 425 | CLANG_ENABLE_MODULES = YES; 426 | CLANG_ENABLE_OBJC_ARC = YES; 427 | CLANG_WARN_BOOL_CONVERSION = YES; 428 | CLANG_WARN_CONSTANT_CONVERSION = YES; 429 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 430 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 431 | CLANG_WARN_EMPTY_BODY = YES; 432 | CLANG_WARN_ENUM_CONVERSION = YES; 433 | CLANG_WARN_INFINITE_RECURSION = YES; 434 | CLANG_WARN_INT_CONVERSION = YES; 435 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 436 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 437 | CLANG_WARN_UNREACHABLE_CODE = YES; 438 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 439 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 440 | COPY_PHASE_STRIP = NO; 441 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 442 | ENABLE_NS_ASSERTIONS = NO; 443 | ENABLE_STRICT_OBJC_MSGSEND = YES; 444 | GCC_C_LANGUAGE_STANDARD = gnu99; 445 | GCC_NO_COMMON_BLOCKS = YES; 446 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 447 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 448 | GCC_WARN_UNDECLARED_SELECTOR = YES; 449 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 450 | GCC_WARN_UNUSED_FUNCTION = YES; 451 | GCC_WARN_UNUSED_VARIABLE = YES; 452 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 453 | MTL_ENABLE_DEBUG_INFO = NO; 454 | SDKROOT = iphoneos; 455 | VALIDATE_PRODUCT = YES; 456 | }; 457 | name = Release; 458 | }; 459 | 64EC7E651E49735C003D1BA0 /* Debug */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | INFOPLIST_FILE = SCAdViewDemo/Info.plist; 464 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 465 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 466 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemo; 467 | PRODUCT_NAME = "$(TARGET_NAME)"; 468 | }; 469 | name = Debug; 470 | }; 471 | 64EC7E661E49735C003D1BA0 /* Release */ = { 472 | isa = XCBuildConfiguration; 473 | buildSettings = { 474 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 475 | INFOPLIST_FILE = SCAdViewDemo/Info.plist; 476 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 478 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemo; 479 | PRODUCT_NAME = "$(TARGET_NAME)"; 480 | }; 481 | name = Release; 482 | }; 483 | 64EC7E681E49735C003D1BA0 /* Debug */ = { 484 | isa = XCBuildConfiguration; 485 | buildSettings = { 486 | BUNDLE_LOADER = "$(TEST_HOST)"; 487 | INFOPLIST_FILE = SCAdViewDemoTests/Info.plist; 488 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 489 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemoTests; 490 | PRODUCT_NAME = "$(TARGET_NAME)"; 491 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCAdViewDemo.app/SCAdViewDemo"; 492 | }; 493 | name = Debug; 494 | }; 495 | 64EC7E691E49735C003D1BA0 /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | BUNDLE_LOADER = "$(TEST_HOST)"; 499 | INFOPLIST_FILE = SCAdViewDemoTests/Info.plist; 500 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 501 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemoTests; 502 | PRODUCT_NAME = "$(TARGET_NAME)"; 503 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SCAdViewDemo.app/SCAdViewDemo"; 504 | }; 505 | name = Release; 506 | }; 507 | 64EC7E6B1E49735C003D1BA0 /* Debug */ = { 508 | isa = XCBuildConfiguration; 509 | buildSettings = { 510 | INFOPLIST_FILE = SCAdViewDemoUITests/Info.plist; 511 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 512 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemoUITests; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | TEST_TARGET_NAME = SCAdViewDemo; 515 | }; 516 | name = Debug; 517 | }; 518 | 64EC7E6C1E49735C003D1BA0 /* Release */ = { 519 | isa = XCBuildConfiguration; 520 | buildSettings = { 521 | INFOPLIST_FILE = SCAdViewDemoUITests/Info.plist; 522 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 523 | PRODUCT_BUNDLE_IDENTIFIER = com.Chan4iOS.SCAdViewDemoUITests; 524 | PRODUCT_NAME = "$(TARGET_NAME)"; 525 | TEST_TARGET_NAME = SCAdViewDemo; 526 | }; 527 | name = Release; 528 | }; 529 | /* End XCBuildConfiguration section */ 530 | 531 | /* Begin XCConfigurationList section */ 532 | 64EC7E321E49735C003D1BA0 /* Build configuration list for PBXProject "SCAdViewDemo" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 64EC7E621E49735C003D1BA0 /* Debug */, 536 | 64EC7E631E49735C003D1BA0 /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | defaultConfigurationName = Release; 540 | }; 541 | 64EC7E641E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemo" */ = { 542 | isa = XCConfigurationList; 543 | buildConfigurations = ( 544 | 64EC7E651E49735C003D1BA0 /* Debug */, 545 | 64EC7E661E49735C003D1BA0 /* Release */, 546 | ); 547 | defaultConfigurationIsVisible = 0; 548 | defaultConfigurationName = Release; 549 | }; 550 | 64EC7E671E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemoTests" */ = { 551 | isa = XCConfigurationList; 552 | buildConfigurations = ( 553 | 64EC7E681E49735C003D1BA0 /* Debug */, 554 | 64EC7E691E49735C003D1BA0 /* Release */, 555 | ); 556 | defaultConfigurationIsVisible = 0; 557 | defaultConfigurationName = Release; 558 | }; 559 | 64EC7E6A1E49735C003D1BA0 /* Build configuration list for PBXNativeTarget "SCAdViewDemoUITests" */ = { 560 | isa = XCConfigurationList; 561 | buildConfigurations = ( 562 | 64EC7E6B1E49735C003D1BA0 /* Debug */, 563 | 64EC7E6C1E49735C003D1BA0 /* Release */, 564 | ); 565 | defaultConfigurationIsVisible = 0; 566 | defaultConfigurationName = Release; 567 | }; 568 | /* End XCConfigurationList section */ 569 | }; 570 | rootObject = 64EC7E2F1E49735C003D1BA0 /* Project object */; 571 | } 572 | -------------------------------------------------------------------------------- /SCAdViewDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SCAdViewDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /SCAdViewDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/刘备.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "刘备.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/刘备.imageset/刘备.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCAdView/623fc856122dd52bdee14b7adc919fea6e85f03a/SCAdViewDemo/Assets.xcassets/刘备.imageset/刘备.jpg -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/嬴政.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "嬴政.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/嬴政.imageset/嬴政.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCAdView/623fc856122dd52bdee14b7adc919fea6e85f03a/SCAdViewDemo/Assets.xcassets/嬴政.imageset/嬴政.jpg -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/李白.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "李白.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/李白.imageset/李白.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCAdView/623fc856122dd52bdee14b7adc919fea6e85f03a/SCAdViewDemo/Assets.xcassets/李白.imageset/李白.jpg -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/韩信.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "韩信.jpg", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "scale" : "2x" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SCAdViewDemo/Assets.xcassets/韩信.imageset/韩信.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kuah/SCAdView/623fc856122dd52bdee14b7adc919fea6e85f03a/SCAdViewDemo/Assets.xcassets/韩信.imageset/韩信.jpg -------------------------------------------------------------------------------- /SCAdViewDemo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SCAdViewDemo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /SCAdViewDemo/HeroModel.h: -------------------------------------------------------------------------------- 1 | // 2 | // HeroModel.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/8. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HeroModel : NSObject 12 | /** 13 | * 图片名称 14 | */ 15 | @property (nonatomic,strong)NSString * imageName; 16 | /** 17 | * 介绍 18 | */ 19 | @property (nonatomic,strong)NSString *introduction; 20 | @end 21 | -------------------------------------------------------------------------------- /SCAdViewDemo/HeroModel.m: -------------------------------------------------------------------------------- 1 | // 2 | // HeroModel.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/8. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "HeroModel.h" 10 | 11 | @implementation HeroModel 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /SCAdViewDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 0.62 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /SCAdViewDemo/SCAdDemoCollectionViewCell.h: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdDemoCollectionViewCell.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "SCAdViewRenderDelegate.h" 11 | @interface SCAdDemoCollectionViewCell : UICollectionViewCell 12 | @property (strong, nonatomic) IBOutlet UIImageView *showImage; 13 | @property (strong, nonatomic) IBOutlet UIView *bgView; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /SCAdViewDemo/SCAdDemoCollectionViewCell.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdDemoCollectionViewCell.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "SCAdDemoCollectionViewCell.h" 10 | #import "HeroModel.h" 11 | @implementation SCAdDemoCollectionViewCell 12 | -(void)setModel:(id)model{ 13 | 14 | if ([model isKindOfClass:[HeroModel class]]) { 15 | HeroModel *h_model = model; 16 | _showImage.image = [UIImage imageNamed:h_model.imageName]; 17 | }else{ 18 | NSString *imageName = model; 19 | _showImage.image = [UIImage imageNamed:imageName]; 20 | } 21 | } 22 | - (void)awakeFromNib { 23 | [super awakeFromNib]; 24 | // Initialization code 25 | _showImage.layer.masksToBounds = YES; 26 | _showImage.layer.cornerRadius = 10; 27 | self.bgView.layer.masksToBounds = YES; 28 | self.bgView.layer.cornerRadius = 10; 29 | self.bgView.layer.shadowColor = [UIColor blackColor].CGColor; 30 | self.bgView.layer.shadowOpacity = 0.8; 31 | self.bgView.layer.shadowRadius = 6.0f; 32 | self.bgView.layer.shadowOffset = CGSizeMake(6, 6); 33 | self.clipsToBounds =NO; 34 | self.bgView.clipsToBounds =NO; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /SCAdViewDemo/SCAdDemoCollectionViewCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SCAdViewDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /SCAdViewDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "SCAdView.h" 11 | #import "HeroModel.h" 12 | @interface ViewController () 13 | { 14 | SCAdView *_adView; 15 | } 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | self.view.backgroundColor = [UIColor whiteColor]; 24 | 25 | // [self showAdVertically];//垂直显示 26 | [self showAdHorizontally];//水平显示 27 | 28 | 29 | CGFloat btnWidth = 100; 30 | CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; 31 | CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; 32 | CGFloat margin_x = (screenWidth-btnWidth)/2; 33 | UIButton *btn = [[UIButton alloc]initWithFrame:(CGRect){margin_x-btnWidth-20,screenHeight-110,btnWidth,55}]; 34 | btn.backgroundColor = [UIColor redColor]; 35 | [btn setTitle:@"play" forState:UIControlStateNormal]; 36 | btn.alpha = 0.8; 37 | [self.view addSubview:btn]; 38 | [btn addTarget:self action:@selector(play) forControlEvents:UIControlEventTouchUpInside]; 39 | UIButton *btn1 = [[UIButton alloc]initWithFrame:(CGRect){margin_x,screenHeight-110,btnWidth,55}]; 40 | btn1.backgroundColor = [UIColor blueColor]; 41 | [btn1 setTitle:@"pause" forState:UIControlStateNormal]; 42 | btn1.alpha = 0.8; 43 | [self.view addSubview:btn1]; 44 | [btn1 addTarget:self action:@selector(pause) forControlEvents:UIControlEventTouchUpInside]; 45 | UIButton *btn2 = [[UIButton alloc]initWithFrame:(CGRect){margin_x+btnWidth+20,screenHeight-110,btnWidth,55}]; 46 | btn2.backgroundColor = [UIColor greenColor]; 47 | [btn2 setTitle:@"refresh" forState:UIControlStateNormal]; 48 | btn2.alpha = 0.8; 49 | [self.view addSubview:btn2]; 50 | [btn2 addTarget:self action:@selector(refresh) forControlEvents:UIControlEventTouchUpInside]; 51 | 52 | btn.layer.masksToBounds =YES; 53 | btn1.layer.masksToBounds = YES; 54 | btn2.layer.masksToBounds = YES; 55 | 56 | btn.layer.cornerRadius = 10; 57 | btn1.layer.cornerRadius = 10; 58 | btn2.layer.cornerRadius = 10; 59 | 60 | } 61 | #pragma mark --垂直模式 62 | /** 63 | * @brief 垂直显示 64 | */ 65 | -(void)showAdVertically{ 66 | 67 | SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) { 68 | 69 | //必须参数 70 | builder.adArray = @[@"刘备",@"李白",@"嬴政",@"韩信"]; 71 | builder.viewFrame = (CGRect){0,0,self.view.bounds.size.width,self.view.bounds.size.height/1.5f}; 72 | builder.adItemSize = (CGSize){self.view.bounds.size.width/2.5f,self.view.bounds.size.width/4.f}; 73 | builder.secondaryItemMinAlpha = 0.6;//非必要参数,设置非主要广告的alpa值 74 | builder.autoScrollDirection = SCAdViewScrollDirectionTop;//设置垂直向下滚动 75 | builder.itemCellNibName = @"SCAdDemoCollectionViewCell"; 76 | 77 | //非必要参数 78 | builder.allowedInfinite = NO; //非必要参数 :设置不无限循环轮播,默认为Yes 79 | // builder.minimumLineSpacing = 40; //非必要参数: 如需要可填写,默认会自动计算 80 | // builder.scrollEnabled = NO;//非必要参数 81 | builder.threeDimensionalScale = 1.45;//非必要参数: 若需要使用threeD效果,则需要填写放大或缩小倍数 82 | // builder.allowedInfinite = NO;//非必要参数 : 如设置为NO,则按所需显示,不会无限轮播,也不具备轮播功能,默认为yes 83 | 84 | }]; 85 | adView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:0.2]; 86 | adView.delegate = self; 87 | _adView = adView; 88 | [self.view addSubview:adView]; 89 | } 90 | #pragma mark -水平模式 91 | /** 92 | * @brief 水平显示 93 | */ 94 | -(void)showAdHorizontally{ 95 | NSArray *testArray =@[@"刘备",@"李白",@"嬴政",@"韩信"]; 96 | //模拟服务器获取到的数据 97 | NSMutableArray *arrayFromService = [NSMutableArray array]; 98 | for (NSString *text in testArray) { 99 | HeroModel *hero = [HeroModel new]; 100 | hero.imageName = text; 101 | hero.introduction = [NSString stringWithFormat:@"我是王者农药的:---->%@",text]; 102 | [arrayFromService addObject:hero]; 103 | } 104 | 105 | SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) { 106 | builder.adArray = arrayFromService; 107 | builder.viewFrame = (CGRect){0,100,self.view.bounds.size.width,self.view.bounds.size.width/2.f}; 108 | builder.adItemSize = (CGSize){self.view.bounds.size.width/2.5f,self.view.bounds.size.width/4.f}; 109 | builder.minimumLineSpacing = 0; 110 | builder.secondaryItemMinAlpha = 0.6; 111 | builder.threeDimensionalScale = 1.45; 112 | builder.itemCellNibName = @"SCAdDemoCollectionViewCell"; 113 | }]; 114 | adView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:0.2]; 115 | adView.delegate = self; 116 | _adView = adView; 117 | [self.view addSubview:adView]; 118 | 119 | } 120 | #pragma mark -delegate 121 | 122 | -(void)sc_didClickAd:(id)adModel{ 123 | NSLog(@"sc_didClickAd-->%@",adModel); 124 | if ([adModel isKindOfClass:[HeroModel class]]) { 125 | NSLog(@"%@",((HeroModel*)adModel).introduction); 126 | } 127 | } 128 | 129 | -(void)sc_scrollToIndex:(NSInteger)index{ 130 | NSLog(@"sc_scrollToIndex-->%ld",index); 131 | } 132 | 133 | 134 | #pragma mark -operation 135 | -(void)play{ 136 | [_adView play]; 137 | } 138 | -(void)pause{ 139 | [_adView pause]; 140 | } 141 | -(void)refresh{ 142 | [_adView reloadWithDataArray:@[@"李白",@"李白",@"李白"]]; 143 | } 144 | 145 | 146 | 147 | - (void)didReceiveMemoryWarning { 148 | [super didReceiveMemoryWarning]; 149 | // Dispose of any resources that can be recreated. 150 | } 151 | 152 | 153 | @end 154 | -------------------------------------------------------------------------------- /SCAdViewDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // SCAdViewDemo 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SCAdViewDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SCAdViewDemoTests/SCAdViewDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdViewDemoTests.m 3 | // SCAdViewDemoTests 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SCAdViewDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SCAdViewDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /SCAdViewDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /SCAdViewDemoUITests/SCAdViewDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // SCAdViewDemoUITests.m 3 | // SCAdViewDemoUITests 4 | // 5 | // Created by 陈世翰 on 17/2/7. 6 | // Copyright © 2017年 Coder Chan. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface SCAdViewDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation SCAdViewDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | --------------------------------------------------------------------------------