让group tableview每个section拥有阴影和圆角
#import <UIKit/UIKit.h> @class GroupShadowTableView;
@protocol GroupShadowTableViewDelegate <NSObject> @optional
- (void)groupShadowTableView:(GroupShadowTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; - (CGFloat)groupShadowTableView:(GroupShadowTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; - (BOOL)groupShadowTableView:(GroupShadowTableView *)tableView canSelectAtSection:(NSInteger)section; @end @protocol GroupShadowTableViewDataSource <NSObject>
@optional
- (NSInteger)numberOfSectionsInGroupShadowTableView:(GroupShadowTableView *)tableView; @required - (NSInteger)groupShadowTableView:(GroupShadowTableView *)tableView numberOfRowsInSection:(NSInteger)section; - (UITableViewCell *)groupShadowTableView:(GroupShadowTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; @end @interface GroupShadowTableView : UITableView
/**
是否显示分割线 默认YES
*/
@property (nonatomic,assign) BOOL showSeparator; @property (nonatomic,weak) IBOutlet id <GroupShadowTableViewDelegate> groupShadowDelegate; @property (nonatomic,weak) IBOutlet id <GroupShadowTableViewDataSource> groupShadowDataSource; @property (nonatomic,copy) NSInteger (^numberOfSectionsInGroupShadowTableView)(GroupShadowTableView *tableView); @property (nonatomic,copy) NSInteger (^numberOfRowsInSection)(GroupShadowTableView *tableView,NSInteger section); @property (nonatomic,copy) CGFloat (^heightForRowAtIndexPath)(GroupShadowTableView *tableView,NSIndexPath *indexPath); @property (nonatomic,copy) UITableViewCell * (^cellForRowAtIndexPath)(GroupShadowTableView *tableView,NSIndexPath *indexPath); @property (nonatomic,copy) void (^didSelectRowAtIndexPath)(GroupShadowTableView *tableView,NSIndexPath *indexPath); @end
#import "GroupShadowTableView.h"
@interface UIView (Add)
- (void)setCornerRadius:(CGFloat)radius withShadow:(BOOL)shadow withOpacity:(CGFloat)opacity;
@end
@implementation UIView (Add)
- (void)setCornerRadius:(CGFloat)radius withShadow:(BOOL)shadow withOpacity:(CGFloat)opacity {
self.layer.cornerRadius = radius;
if (shadow) {
self.layer.shadowColor = [UIColor lightGrayColor].CGColor;
self.layer.shadowOpacity = opacity;
self.layer.shadowOffset = CGSizeMake(-4, 4);
self.layer.shadowRadius = 4;
self.layer.shouldRasterize = NO;
self.layer.shadowPath = [[UIBezierPath bezierPathWithRoundedRect:[self bounds] cornerRadius:radius] CGPath];
}
self.layer.masksToBounds = !shadow;
}
@end
@class PlainTableViewCell;
@protocol PlainTableViewCellDelegate <NSObject>
- (NSInteger)plainTableViewCell:(PlainTableViewCell *)cell numberOfRowsInSection:(NSInteger)section;
- (CGFloat)plainTableViewCell:(PlainTableViewCell *)cell heightForRowAtIndexPath:(NSIndexPath *)indexPath;
- (UITableViewCell *)plainTableViewCell:(PlainTableViewCell *)cell cellForRowAtIndexPath:(NSIndexPath *)indexPath;
@end
@interface PlainTableViewCell : UITableViewCell <UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,weak,nullable) id<PlainTableViewCellDelegate> delegate;
@property (nonatomic,assign) BOOL showSeparator;
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,copy) NSInteger (^numberOfRowsInSection)(PlainTableViewCell *plainCell,NSInteger section);
@property (nonatomic,copy) UITableViewCell * (^cellForRowAtIndexPath)(PlainTableViewCell *plainCell,NSIndexPath *indexPath);
@property (nonatomic,copy) CGFloat (^heightForRowAtIndexPath)(PlainTableViewCell *plainCell,NSIndexPath *indexPath);
@property (nonatomic,copy) void (^didSelectRowAtIndexPath)(PlainTableViewCell *plainCell,NSIndexPath *indexPath);
- (void)deselectCell;
- (void)selectCell:(NSInteger)row;
@end
@interface GroupShadowTableView () <UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,weak) PlainTableViewCell *selectedCell;
@property (nonatomic,strong) NSIndexPath *selectedIndexPath;
@end
@implementation GroupShadowTableView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initializeUI];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
self = [super initWithFrame:frame style:style];
if (self) {
[self initializeUI];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeUI];
}
return self;
}
-(void)initializeUI {
[self registerClass:[PlainTableViewCell class] forCellReuseIdentifier:@"PlainTableViewCell"];
self.delegate = self;
self.dataSource = self;
}
- (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated {
PlainTableViewCell *cell = [self cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:indexPath.section]];
[cell.tableView deselectRowAtIndexPath:[NSIndexPath indexPathForRow:indexPath.row inSection:0] animated:animated];
}
//MARK: - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
if (self.numberOfSectionsInGroupShadowTableView) {
return self.numberOfSectionsInGroupShadowTableView(self);
}else if (self.groupShadowDataSource && [self.groupShadowDataSource respondsToSelector:@selector(numberOfSectionsInGroupShadowTableView:)]) {
return [self.groupShadowDataSource numberOfSectionsInGroupShadowTableView:self];
}
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
PlainTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PlainTableViewCell"];
cell.showSeparator = self.showSeparator;
cell.tableView.separatorInset = self.separatorInset;
if (self.groupShadowDelegate && [self.groupShadowDelegate respondsToSelector:@selector(groupShadowTableView:canSelectAtSection:)]) {
cell.tableView.allowsSelection = [self.groupShadowDelegate groupShadowTableView:self canSelectAtSection:indexPath.section];
}else {
cell.tableView.allowsSelection = self.allowsSelection;
}
cell.tag = indexPath.section + 100; //标记是第几组
__weak typeof(self) weakSelf = self;
[cell setNumberOfRowsInSection:^NSInteger(PlainTableViewCell *plainTableViewCell, NSInteger section) {
if (weakSelf.numberOfRowsInSection) {
return weakSelf.numberOfRowsInSection(weakSelf,section);
}else if (weakSelf.groupShadowDataSource && [weakSelf.groupShadowDataSource respondsToSelector:@selector(groupShadowTableView:numberOfRowsInSection:)]) {
return [weakSelf.groupShadowDataSource groupShadowTableView:weakSelf numberOfRowsInSection:section];
}
return 0;
}];
[cell setHeightForRowAtIndexPath:^CGFloat(PlainTableViewCell *plainTableViewCell, NSIndexPath *indexPath) {
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:plainTableViewCell.tag - 100];
if (weakSelf.heightForRowAtIndexPath) {
return weakSelf.heightForRowAtIndexPath(weakSelf,newIndexPath);
}else if (weakSelf.groupShadowDelegate && [weakSelf.groupShadowDelegate respondsToSelector:@selector(groupShadowTableView:heightForRowAtIndexPath:)]) {
return [weakSelf.groupShadowDelegate groupShadowTableView:weakSelf heightForRowAtIndexPath:newIndexPath];
}
return 0;
}];
[cell setCellForRowAtIndexPath:^UITableViewCell *(PlainTableViewCell *plainTableViewCell, NSIndexPath *indexPath) {
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:plainTableViewCell.tag - 100];
if (weakSelf.cellForRowAtIndexPath) {
return weakSelf.cellForRowAtIndexPath(weakSelf,newIndexPath);
}else if (weakSelf.groupShadowDataSource && [weakSelf.groupShadowDataSource respondsToSelector:@selector(groupShadowTableView:cellForRowAtIndexPath:)]) {
return [weakSelf.groupShadowDataSource groupShadowTableView:weakSelf cellForRowAtIndexPath:newIndexPath];
}
return nil;
}];
[cell setDidSelectRowAtIndexPath:^(PlainTableViewCell *plainTableViewCell, NSIndexPath *indexPath) {
NSInteger actualSection = plainTableViewCell.tag - 100;
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:actualSection];
if (weakSelf.selectedCell && weakSelf.selectedCell != plainTableViewCell) {
[weakSelf.selectedCell deselectCell];
}
if (weakSelf.didSelectRowAtIndexPath) {
weakSelf.didSelectRowAtIndexPath(weakSelf,newIndexPath);
}else if (weakSelf.groupShadowDelegate && [weakSelf.groupShadowDelegate respondsToSelector:@selector(groupShadowTableView:didSelectRowAtIndexPath:)]) {
[weakSelf.groupShadowDelegate groupShadowTableView:weakSelf didSelectRowAtIndexPath:newIndexPath];
}
self.selectedIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:actualSection];
self.selectedCell = plainTableViewCell;
}];
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
PlainTableViewCell *ptCell = (PlainTableViewCell *)cell;
[ptCell.tableView reloadData];
if (indexPath.section == self.selectedIndexPath.section) {
[self.selectedCell selectCell:self.selectedIndexPath.row];
}
}
//MARK: - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger totalRows = 0;
if (self.numberOfRowsInSection) {
totalRows = self.numberOfRowsInSection(self,indexPath.section);
}else if (self.groupShadowDataSource && [self.groupShadowDataSource respondsToSelector:@selector(groupShadowTableView:numberOfRowsInSection:)]) {
totalRows = [self.groupShadowDataSource groupShadowTableView:self numberOfRowsInSection:indexPath.section];
}
CGFloat totalHeight = 0;
for (int i = 0; i < totalRows; i ++) {
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:i inSection:indexPath.section];
if (self.heightForRowAtIndexPath) {
totalHeight += self.heightForRowAtIndexPath(self,newIndexPath);
}else if (self.groupShadowDelegate && [self.groupShadowDelegate respondsToSelector:@selector(groupShadowTableView:heightForRowAtIndexPath:)]) {
totalHeight += [self.groupShadowDelegate groupShadowTableView:self heightForRowAtIndexPath:newIndexPath];
}
}
return totalHeight;
}
@end
//MARK: - PlainTableViewCell
@implementation PlainTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSeparatorStyleNone;
self.tableView = [[UITableView alloc]initWithFrame:CGRectInset(self.bounds, 15, 0) style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.scrollEnabled = NO;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.contentView addSubview:self.tableView];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
[self.tableView setCornerRadius:8 withShadow:YES withOpacity:0.6];
}
//MARK: - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if (self.numberOfRowsInSection) {
return self.numberOfRowsInSection(self,self.tag-100);
}else {
if (self.delegate && [self.delegate respondsToSelector:@selector(plainTableViewCell:numberOfRowsInSection:)]) {
return [self.delegate plainTableViewCell:self numberOfRowsInSection:self.tag -100];
}
}
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell;
if (self.cellForRowAtIndexPath) {
cell = self.cellForRowAtIndexPath(self,indexPath);
}else {
if (self.delegate && [self.delegate respondsToSelector:@selector(plainTableViewCell:cellForRowAtIndexPath:)]) {
cell = [self.delegate plainTableViewCell:self cellForRowAtIndexPath:indexPath];
}
}
NSAssert(cell, @"Cell不能为空");
return cell;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
CGFloat cornerRadius = 8.f;
cell.backgroundColor = UIColor.clearColor;
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
CAShapeLayer *backgroundLayer = [[CAShapeLayer alloc] init];
CGMutablePathRef pathRef = CGPathCreateMutable();
CGRect bounds = cell.bounds;
NSInteger numberOfRows = 0;
if (self.numberOfRowsInSection) {
numberOfRows = self.numberOfRowsInSection(self,self.tag -100);
}
BOOL needSeparator = NO;
if (indexPath.row == 0 && numberOfRows == 1) {
CGPathAddRoundedRect(pathRef, nil, bounds, cornerRadius, cornerRadius);
}else if (indexPath.row == 0) {
// 初始起点为cell的左下角坐标
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds), CGRectGetMidX(bounds), CGRectGetMinY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds));
needSeparator = YES;
} else if (indexPath.row == numberOfRows -1) {
// 初始起点为cell的左上角坐标
CGPathMoveToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMinY(bounds));
CGPathAddArcToPoint(pathRef, nil, CGRectGetMinX(bounds), CGRectGetMaxY(bounds), CGRectGetMidX(bounds), CGRectGetMaxY(bounds), cornerRadius);
CGPathAddArcToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMaxY(bounds), CGRectGetMaxX(bounds), CGRectGetMidY(bounds), cornerRadius);
CGPathAddLineToPoint(pathRef, nil, CGRectGetMaxX(bounds), CGRectGetMinY(bounds));
} else {
CGPathAddRect(pathRef, nil, bounds);
needSeparator = YES;
}
layer.path = pathRef;
backgroundLayer.path = pathRef;
CFRelease(pathRef);
layer.fillColor = [UIColor whiteColor].CGColor;
if (self.showSeparator && needSeparator) {
CALayer *lineLayer = [[CALayer alloc] init];
CGFloat lineHeight = (1.f / [UIScreen mainScreen].scale);
lineLayer.frame = CGRectMake(self.separatorInset.left, bounds.size.height - lineHeight, bounds.size.width - (self.separatorInset.left + self.separatorInset.right), lineHeight);
lineLayer.backgroundColor = self.tableView.separatorColor.CGColor;
[layer addSublayer:lineLayer];
}
UIView *roundView = [[UIView alloc] initWithFrame:bounds];
[roundView.layer insertSublayer:layer atIndex:0];
roundView.backgroundColor = UIColor.clearColor;
cell.backgroundView = roundView;
UIView *selectedBackgroundView = [[UIView alloc] initWithFrame:cell.bounds];
backgroundLayer.fillColor = [UIColor groupTableViewBackgroundColor].CGColor;
[selectedBackgroundView.layer insertSublayer:backgroundLayer below:cell.layer];
selectedBackgroundView.backgroundColor = UIColor.clearColor;
cell.selectedBackgroundView = selectedBackgroundView;
}
//MARK: - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.didSelectRowAtIndexPath) {
self.didSelectRowAtIndexPath(self,indexPath);
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.heightForRowAtIndexPath) {
return self.heightForRowAtIndexPath(self,indexPath);
}else {
if (self.delegate && [self.delegate respondsToSelector:@selector(plainTableViewCell:heightForRowAtIndexPath:)]) {
return [self.delegate plainTableViewCell:self heightForRowAtIndexPath:indexPath];
}
}
return 0;
}
- (void)deselectCell {
[self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:NO];
}
- (void)selectCell:(NSInteger)row {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0];
[self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
}
@end
#import "ViewController.h"
#import "GroupShadowTableView.h" @interface ViewController () <GroupShadowTableViewDelegate,GroupShadowTableViewDataSource>
@property (weak, nonatomic) IBOutlet GroupShadowTableView *tableView; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.tableView.groupShadowDelegate = self;
self.tableView.groupShadowDataSource = self;
self.tableView.showSeparator = YES;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} //MARK: - GroupShadowTableViewDataSource
- (NSInteger)numberOfSectionsInGroupShadowTableView:(GroupShadowTableView *)tableView {
return 5;
}
- (NSInteger)groupShadowTableView:(GroupShadowTableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 4;
} - (UITableViewCell *)groupShadowTableView:(GroupShadowTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
cell.textLabel.text = [NSString stringWithFormat:@"section -> %@ ; row -> %@",@(indexPath.section) ,@(indexPath.row)];
return cell; } //MARK: - GroupShadowTableViewDelegate
- (CGFloat)groupShadowTableView:(GroupShadowTableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 60;
} - (void)groupShadowTableView:(GroupShadowTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES]; } @end
让group tableview每个section拥有阴影和圆角的更多相关文章
- tableview: 实现tableview 的 section header 跟随tableview滑动
方法一:(只有一个headerView)一段 如果你的tableview恰好只有一个headerView,实现这种效果就好办了.把要设置的headerView设置成tableView的header而不 ...
- UIView阴影和圆角的关系
UIView阴影和圆角的关系 UIView 的 clipsToBounds属性和CALayer的setMasksToBounds属性表达的意思是一致的. 取值:BOOL(YES/NO) 作用:决定 ...
- (一一九)通过CALayer实现阴影、圆角、边框和3D变换
在每个View上都有一个CALayer作为父图层,View的内容作为子层显示,通过layer的contents属性决定了要显示的内容,通过修改过layer的一些属性可以实现一些华丽的效果. [阴影和圆 ...
- swift 设置阴影和圆角
1.正常view设置阴影 func setShadow(view:UIView,sColor:UIColor,offset:CGSize, opacity:Float,radius:CGFloat) ...
- CSS 笔记——阴影、圆角、旋转、光标
7. 阴影.圆角.旋转.光标 (1)box-shadow 阴影 基本语法 text-shadow: h-shadow v-shadow blur color; box-shadow: h-shadow ...
- iOS7中group类型tableview的section间距设置
1.如果是首行,检查是否设置了headerView. 2.其他设置tableView . sectionFooterHeight = 1.0. 这个距离的计算是header的高度加上footer的 ...
- 如何改变tableview的section的颜色
方法一:调用 - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIV ...
- 如何设置static tableview的section区域高度
重写代理方法- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { i ...
- 由于TableView的Section的头部和尾部高度设置的不规范引起的部分Section中的图片无法正常显示
当tableview的组的头部和尾部的高度设置如下时: -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(N ...
随机推荐
- 2016年最值得新手程序猿阅读的书:《增长project师指南》
这本书的来源于根据我在<Repractise简单介绍篇:Web开发的七天里>中所说的 Web 开发的七个步骤而展开的电子书.当然它也是一个 APP.它一本关于怎样成为增长project师的 ...
- 解决Android Studio下Element layer-list must be declared问题
近期将一个项目从Eclipse转到Android Studio. 项目中使用了环信demo中的一些xml资源,转换后发现color资源目录下诸如layer-list或者shape等标签报Element ...
- 脱了裤子放屁之std::string
一个天天跟c#奋斗的苦逼c++程序猿 改自己曾经代码的时候发现有例如以下几行. char szPath[MAX_PATH] = {0}; GetModuleFileNameA(NULL,szPath, ...
- Möbius strip
en.wikipedia.org/wiki/Möbius_strip http://mechproto.olin.edu/final_projects/average_jo.html Fabricat ...
- C/C++笔记之char *与wchar_t *的相互转换
char *和wchar_t *的相互转换,可使用标准库函数 size_t mbstowcs(wchar_t *wcstr, const char *mbstr, size_t count)和size ...
- 面试算法爱好者书籍/OJ推荐
面试算法爱好者书籍/OJ推荐 这个书单也基本适用于准备面试. 一.教科书 基本上一般的算法课本介绍的范围都不会超出算法导论和算法引论的范围.读完这两本书,其它的算法课本大致翻翻也就知道是什么货色了. ...
- ABAP OLE常用方法和属性
转自 http://www.cnblogs.com/eric0701/p/5213694.htmlSAP EXCEL OLE常用方法和属性 附加网上找到的比较好的源代码示例一份 1.ole中如何保存和 ...
- 升级python到最新2.7.13
python2.7是2.X的最后一个版本,同时也加入了一部分3.X的新特性.并且具有更好的性能,修改多个bug.所以决定升级到最新的2.7版,我的目前的版本是2.6.6 查看当前python版本 # ...
- testing
doctest_test.py def square(x): ''' 这里需要空格 >>> square(2) 4 啦啦 >>> square(3) 9 上不一行能 ...
- 一个轻量级AOP的实现(开源)
事先声明,本项目参考AOP in C#和园内大神张逸的文章,思路神马的都不是自己的! 为了让项目的代码看起来更干净,需要一个AOP! 于是就实现了一个非常简单的,非常轻量级,有多轻量级呢? 实现的AO ...