我的第一 Swift 源 PRSlideView-Swift - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
Elethom
V2EX    iDev

我的第一 Swift 源 PRSlideView-Swift

  •  3
     
  •   Elethom
    Elethom 2015-01-26 20:56:43 +08:00 3835 次点击
    这是一个创建于 3922 天前的主题,其中的信息可能已经有所发展或是发生改变。

    昨天用 Swift 重了之前的一源 PRSlideView, 今天整理好到 GitHub 上了.

    注: 有到 CocoaPods 是因有足的磁空安新的工具通 CocoaPods 前. 你可以通我捐一台 最新的配 MacBook Pro 以解. XD

    View on GitHub

    PRSlideView-Swift

    This is the Swift language version of PRSlideView.

    General

    Slide view with gracefully written UIKit-like methods, delegate and data source protocol. Infinite scrolling supported.

    Note: Auto layout not supported due to the special behaviours of UIScrollView. Please use autoresizing mask instead or wrap it with a container view.

    Usage

    Configure a Slide View

    slideView.delegate = self slideView.dataSource = self slideView.scrollDirection = .Vertical slideView.infiniteScrollingEnabled = true slideView.registerClass( PRAlbumPage.self, identifier: PRAlbumPage.description() ) 

    Create a Slide View Page Subclass

    import UIKit public class PRAlbumPage: PRSlideViewPage { public private(set) var coverImageView: UIImageView required public init(frame: CGRect, identifier: String) { self.coverImageView = UIImageView() super.init(frame: frame, identifier: identifier) let coverImageView = self.coverImageView coverImageView.frame = self.bounds coverImageView.autoresizingMask = (.FlexibleWidth | .FlexibleHeight) coverImageView.contentMode = .ScaleAspectFit selfspan class="p">.addSubview(coverImageView) } required public init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } 

    Use Data Source

    // MARK: PRSlideViewDataSource func numberOfPagesInSlideView(slideView: PRSlideView) -> Int { return self.albumData.count } func slideView(slideView: PRSlideView, pageAtIndex index: Int) -> PRSlideViewPage { let page: PRAlbumPage = slideView.dequeueReusablePageWithIdentifier(PRAlbumPage.description(), index: index) as PRAlbumPage let imageName: String = self.albumData[index].stringByAppendingPathExtension("jpg")! page.coverImageView.image = UIImage(named: imageName) return page } 

    Use Delegate

    // MARK: PRSlideViewDelegate func slideView(slideView: PRSlideView, didScrollToPageAtIndex index: Int) { self.titleLabel.text = self.albumData[index] } func slideView(slideView: PRSlideView, didClickPageAtIndex index: Int) { let alertView: UIAlertView = UIAlertView( title: "You clicked on an album", message: "Title: \(self.albumData[index])", delegate: nil, cancelButtonTitle: "OK") alertView.show() } 

    All done! You can check out the code in the demo provided.

    License

    This code is distributed under the terms and conditions of the MIT license.

    Donate

    You can support me by:

    :-)

    Contact

    19 条回复    2015-01-31 13:40:02 +08:00
    Cee
      &nsp; 1
    Cee  
       2015-01-26 20:59:08 +08:00
    正好看到前来膜拜(ノ 。)ノ
    boom11235
        2
    boom11235  
       2015-01-26 21:02:54 +08:00
    膜拜
    WildCat
        3
    WildCat  
       2015-01-26 21:03:57 +08:00
    膜拜
    WildCat
        4
    WildCat  
       2015-01-26 21:04:35 +08:00
    膜拜(不能队形,楼上被吞了)
    RIcter
        5
    RIcter  
       2015-01-26 21:15:57 +08:00 via iPad
    捐赠顶配的mbpr!
    Elethom
        6
    Elethom  
    OP
       2015-01-26 21:30:20 +08:00   1
    @Cee
    @boom11235
    @WildCat
    @RIcter

    不乖小心 @Livid 打你屁屁喔~
    Livid
        7
    Livid  
    MOD
    PRO
       2015-01-26 21:36:52 +08:00
    正确的姿势是点击主题下面的“感谢”按钮
    kxxoling
        8
    kxxoling  
       2015-01-26 22:24:06 +08:00
    @Livid iPad safari 下点击 +1 无效。
    msxcms
        9
    msxcms  
       2015-01-26 22:28:08 +08:00
    にっこにっこに
    KotiyaSanae
        10
    KotiyaSanae  
       2015-01-27 00:58:58 +08:00
    菊苣菊苣菊
    moliliang
        11
    moliliang  
       2015-01-27 01:31:47 +08:00
    好想看看效果啊。。
    Elethom
        12
    Elethom  
    OP
       2015-01-27 02:59:11 +08:00 via iPhone
    @moliliang
    有 demo, 可以直接 run.
    hkongm
        13
    hkongm  
       2015-01-27 08:49:57 +08:00
    已感谢。
    chenggiant
        14
    chenggiant  
       2015-01-27 09:28:41 +08:00
    已感谢。
    jprovim
        15
    jprovim  
       2015-01-27 10:04:32 +08:00
    的量OK.
    cralison
        16
    cralison  
       2015-01-27 10:17:54 +08:00
    下来学习,谢谢:)
    ciwonderful
        17
    ciwonderful  
       2015-01-27 12:50:07 +08:00
    已感谢。
    tony1016
        18
    tony1016  
       2015-01-27 13:18:41 +08:00
    不错哦,鼓励一下
    Thu
        19
    Thu  
       2015-01-31 13:40:02 +08:00
    Git上给两张效果图就更好了,在下载前能有个总体的印象
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1188 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 17:49 PVG 01:49 LAX 10:49 JFK 13:49
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86