Giter Site home page Giter Site logo

txcustomview's Introduction

先直接上完成后的效果如下: 2018-05-10 20_01_08.gif

具体的demo 详见github地址:https://github.com/TianXin123654/TXCustomView

#TXCustomView用法如下 ####1.朋友圈快速布局,此方法需要创建TXCustomView的大小,然后传入TXCustomPhoto集合,再设置图片的间距,和数量即可。

/**
 快速生成图片框方法(类似九宫格 图片尺寸根据view给定的大小计算)
 
 @param imageArray TXCustomImageArray
 @param interval 图片之间的间距
 @param throwNumber 一排显示的数量
 @param isFit 是否铺满
 */
-(void)setImageArray:(NSArray<TXCustomPhoto *>*)imageArray
    andImageInterval:(NSInteger )interval
      andThrowNumber:(int )throwNumber
   andIsFitImageView:(BOOL)isFit;

实现后的效果:QQ20180509-1332431.png

####2.根据给定的图片大小计算TXCustomView进行布局,此方法需要创建一个TXCustomSizeSettings类,需求中时常会出现一张图片或两张图片大小不一样。

#pragma mark - 下面为拓展自定义属性
/**
 只有一张图片的时候的尺寸
 */
@property (nonatomic, assign)CGSize onlyOneImageSize;//imageSizeForOne

/**
 只有两张图片时候的尺寸
 */
@property (nonatomic, assign)CGSize onlyTwoImageSize;

/**
 只有三张图片时候的尺寸
 */
@property (nonatomic, assign)CGSize onlyThreeImageSize;

/**
 只有一排的时候尺寸
 */
@property (nonatomic, assign)CGSize frontRowImageSize;

然后用法

/**
 快速生成图片框方法(类似九宫格 图片尺寸根据用户给定的imagesize大小生成)
 
 @param imageArray TXCustomImageArray
 @param sets sets TXCustomSetupSettings自定义拓展设置
 */
-(void)setCustomViewSizeWithImageArray:(NSArray<TXCustomPhoto *>*)imageArray
                           withSetting:(TXCustomSizeSettings *)sets;

实现后的效果: image.png

####3.带图片文字描述型。 QQ20180509-1340073.png 我这里提供了几个数据源协议,可以自定义界面的所有view,只需要实现即可:

//自定义顶部view
- (UIView *)customTopView;
//自定义底部view
- (UIView *)customBottomView;
//长按图片弹出View
- (UIView *)customLongPressView;

与此同时,还提供了几种拓展属性,方便使用。如果觉得好用的话,求一个star。

txcustomview's People

Contributors

tianxin123654 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.