GithubHelp home page GithubHelp logo

raybon-lee / lgsettingview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ligoex/lgsettingview

0.0 2.0 0.0 192 KB

三句代码快速集成iOS设置界面

License: MIT License

Objective-C 100.00%

lgsettingview's Introduction

LGSettingView

  • 仅需三句代码即可快速集成设置界面,免去每次开发新应用都要重新布置设置界面的烦恼。
  • Build the Setting View on iOS APP by 3 lines of code.

测试环境

  • Xcode 7.1
  • iOS 8.4,9.1(真机测试通过)

如何使用LGSettingView

  • 1.将LGSettingView文件夹中的所有文件拽入项目中
  • 2.将导入的LGSettingViewController设为设置界面的VC
  • 3.在ViewDidLoad方法中添加组与行
- (void)viewDidLoad {

  
  //三行代码:
  LGSettingSection *section = [LGSettingSection initWithHeaderTitle:[NSString] footerTitle:[NSString]];
  [section addItemWithTitle:[NSString]];
  [self.sections addObject:section];
  
  
  //或以下代码:
  //Set1:添加第一组
  LGSettingSection *section = [LGSettingSection initWithHeaderTitle:[NSString] footerTitle:[NSString]];
  //Set2:添加行
  LGSettingItem *item = [LGSettingItem initWithtitle:[NSString]];
  item.image = [UIImage];
  item.type = [UITableViewCellAccessoryType];
  [section addItem:item];
  //Set3:保存到sections数组
  [self.sections addObject:section];
  
  
  }
  
  
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  if (indexPath.section == 0 && indexPath.row == 1) {
  //添加点击事件
  }
  

##LGSettingSection.h

@interface LGSettingSection : NSObject

/** 头部标题 */
@property (strong, nonatomic) NSString * headerTitle;
/** 尾部标题 */
@property (strong, nonatomic) NSString * footerTitle;
/** 行数 */
@property (strong, nonatomic) NSMutableArray * items;
/** 标题 */
@property (strong, nonatomic) NSString * title;

//类方法 设置headerTitle footerTitle
+ (instancetype)initWithHeaderTitle:(NSString *)headerTitle footerTitle:(NSString *)footerTitle;

-(void)addItem:(LGSettingItem*)item;

-(void)addItemWithTitle:(NSString*)title;
//添加带有左图标的行
-(void)addItemWithTitle:(NSString*)title Image:(UIImage*)image;
@end

##LGSettingItem.h

@interface LGSettingItem : NSObject

/** 标题 */
@property (strong, nonatomic) NSString * title;
/** 左图标 */
@property (strong, nonatomic)  UIImage* image;
/** 行高度 */
@property (nonatomic) CGFloat height;
/** 右图标样式 */
@property (nonatomic) UITableViewCellAccessoryType type;

/** 设置标题值 类方法 */
+ (instancetype)initWithtitle:(NSString *)title;

@end

##参考

  • 文件夹下的LGSettingViewDemo工程

image

##鸣谢

  • iOS_CYX
  • Kenshin Cui's Blog

lgsettingview's People

Contributors

ligoex avatar

Watchers

James Cloos avatar raybon.lee 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.