2017.06.01-2017.07.15
扩大UIButton的点击范围
CGFloat const touchSize = 44; //苹果官方默认44,小于44则为弱反应
CGFloat const sizeMax = - .5;
@implementation YFWLButton //继承UIButton的一个自定义类
///扩大点击范围
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
CGRect bounds = self.bounds;
CGFloat width = MAX(touchSize - bounds.size.width, 0);
CGFloat height = MAX(touchSize - bounds.size.height, 0);
bounds = CGRectInset(bounds, sizeMax * width, sizeMax * height);
return CGRectContainsPoint(bounds, point);
}
操作NSDate的自定义类方法
自定义类方法的.h文件
#import <Foundation/Foundation.h>
@interface YFWLDateManager : NSObject
/**获取day*/
+ (NSInteger)day:(NSDate *)date;
/**获取Month*/
+ (NSInteger)month:(NSDate *)date;
/**获取year*/
+ (NSInteger)year:(NSDate *)date;
/**获取第一天是在第几天*/
+ (NSInteger)firstWeekdayInThisMonth:(NSDate *)date;
/**获取月数总天数*/
+ (NSInteger)totaldaysInThisMonth:(NSDate *)date;
/**获取月份总天数*/
+ (NSInteger)totaldaysInMonth:(NSDate *)date;
/**获取上一个月*/
+ (NSDate *)lastMonth:(NSDate *)date;
/**获取下一个月*/
+ (NSDate*)nextMonth:(NSDate *)date;
/**时间戳转换为时间*/
+ (NSString *) timestampConversionDate:(NSInteger)time Format:(NSString *)format;
/**字符串转换为时间*/
+ (NSDate *) stringConversionDate:(NSString *)dateStr Format:(NSString *)format;
/**时间转换为字符串*/
+ (NSString *) dateConversionString:(NSDate *)date Format:(NSString *)format;
@end
自定义类方法的.m文件
#import "YFWLDateManager.h"
@implementation YFWLDateManager
#pragma mark - 日历方法
+ (NSInteger)day:(NSDate *)date{
NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:date];
return [components day];
}
+ (NSInteger)month:(NSDate *)date{
NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:date];
return [components month];
}
+ (NSInteger)year:(NSDate *)date{
NSDateComponents *components = [[NSCalendar currentCalendar] components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:date];
return [components year];
}
+ (NSInteger)firstWeekdayInThisMonth:(NSDate *)date{
NSCalendar *calendar = [NSCalendar currentCalendar];
[calendar setFirstWeekday:1];//1.Sun. 2.Mon. 3.Thes. 4.Wed. 5.Thur. 6.Fri. 7.Sat.
NSDateComponents *comp = [calendar components:(NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay) fromDate:date];
[comp setDay:1];
NSDate *firstDayOfMonthDate = [calendar dateFromComponents:comp];
NSUInteger firstWeekday = [calendar ordinalityOfUnit:NSCalendarUnitWeekday inUnit:NSCalendarUnitWeekOfMonth forDate:firstDayOfMonthDate];
return firstWeekday - 1;
}
+ (NSInteger)totaldaysInThisMonth:(NSDate *)date{
NSRange totaldaysInMonth = [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:date];
return totaldaysInMonth.length;
}
+ (NSInteger)totaldaysInMonth:(NSDate *)date{
NSRange daysInLastMonth = [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:date];
return daysInLastMonth.length;
}
+ (NSDate *)lastMonth:(NSDate *)date{
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.month = -1;
NSDate *newDate = [[NSCalendar currentCalendar] dateByAddingComponents:dateComponents toDate:date options:0];
return newDate;
}
+ (NSDate*)nextMonth:(NSDate *)date{
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
dateComponents.month = +1;
NSDate *newDate = [[NSCalendar currentCalendar] dateByAddingComponents:dateComponents toDate:date options:0];
return newDate;
}
///时间戳转换为时间
+ (NSString *) timestampConversionDate:(NSInteger)time Format:(NSString *)format{
NSDate *date=[NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:format];
NSString *timeStr=[dateformatter stringFromDate:date];
return timeStr;
}
///字符串转换为时间
+ (NSDate *) stringConversionDate:(NSString *)dateStr Format:(NSString *)format{
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:format];
NSDate *timeStr=[dateformatter dateFromString:dateStr];
return timeStr;
}
///时间转换为字符串
+ (NSString *) dateConversionString:(NSDate *)date Format:(NSString *)format{
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:format];
NSString *timeStr=[dateformatter stringFromDate:date];
return timeStr;
}
自定义Excel的效果视图
达到效果
上下滚动时最上面一行保持不动,左右滚动时最左面一行保持不动,可以斜向滚动。
注:仅供参考,方法比较笨,抛砖引玉,希望大神指点
设计思路导图
参考源码
#import "ZTFormViewController.h"
#import "ZTRoomInfoCollectionViewCell.h"
#import "ZTRoomTitleCollectionViewCell.h"
#import "ZTRoomFilterCollectionViewCell.h"
@interface ZTFormViewController ()<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource,UIGestureRecognizerDelegate>
@property (nonatomic, strong) UIView *headView;
@property (nonatomic, strong) UIView *filterView;
@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UILabel *codeLabel;
@property (nonatomic, strong) UIScrollView *contentScrollView; //内容容器
@property (nonatomic, strong) UICollectionView *topScrollView; //头部滚动
@property (nonatomic, strong) UICollectionView *leftScrollView; //左边滚动
@property (nonatomic, strong) UICollectionView *collectionView; //内容视图
@property (nonatomic, strong) NSMutableArray *leftArray;//左边数组
@property (nonatomic, strong) NSMutableArray *infoArray;//数据数组
@property (nonatomic, strong) NSDate *currentDate;
@property (nonatomic, assign) CGPoint lastOffSet;
@property (nonatomic, assign) BOOL isApartment;
@property (nonatomic, strong) NSString *currentApartID;
@property (nonatomic, strong) NSString *currentHouseID;
@property (nonatomic, strong) NSString *currentMonth;
@property (nonatomic, strong) NSString *nextMonth;
@end
@implementation ZTFormViewController
{
NSInteger _isNextMonth;
}
- (NSMutableArray *)leftArray {
if (!_leftArray) {
_leftArray = [[NSMutableArray alloc]init];
}
return _leftArray;
}
- (NSMutableArray *)infoArray {
if (!_infoArray) {
_infoArray = [[NSMutableArray alloc]init];
}
return _infoArray;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.currentDate = [NSDate date];
self.isApartment = YES;
_isNextMonth = 0;
[self navigationBarSetting];
[self setLabelFC];
[self leftCollectionViewSetting];
[self topCollectionViewSetting];
[self scrollViewSetting];
[self collectionViewSetting];
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
[YFWLHUDManager dismiss];
_bgView.hidden = YES;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
#pragma mark - 导航栏设计
- (void)navigationBarSetting {
self.titleLable.text = @"房态";
self.leftArray = [[NSMutableArray alloc]initWithObjects:@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"",@"", nil];
self.view.backgroundColor = [UIColor appBackgroundColor];
[self.leftButton setImage:[UIImage imageNamed:@"yf_1刷新"] forState:UIControlStateNormal];
self.leftButton.size = CGSizeMake(Size(24), Size(24));
self.leftButton.imageView.contentMode = UIViewContentModeScaleAspectFit;
[self addLeftButtonFouncation:@selector(leftButtonClick)];
}
- (void) leftButtonClick {
}
- (void) setLabelFC {
self.codeLabel = [YFWLFactoryClass CreateLabel:@"房间/日期" FontSize:Size(14) FontColor:[UIColor appBlackTextColor] TextAligment:NSTextAlignmentCenter ToView:self.view];
self.codeLabel.backgroundColor = [UIColor appHeadBgColor];
[self.codeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.equalTo(self.view);
make.width.mas_equalTo(Size(72));
make.height.mas_equalTo(Size(44));
}];
}
#pragma mark - 布局滚动视图
- (void) scrollViewSetting {
self.contentScrollView = [[UIScrollView alloc]init];
self.contentScrollView.showsVerticalScrollIndicator = NO;
self.contentScrollView.showsHorizontalScrollIndicator = NO;
self.contentScrollView.scrollEnabled = YES;
self.contentScrollView.directionalLockEnabled = YES;
self.contentScrollView.bounces = NO;
self.contentScrollView.delegate = self;
self.contentScrollView.backgroundColor = [UIColor appBackgroundColor];
[self.view addSubview:self.contentScrollView];
[self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view);
make.left.equalTo(self.topScrollView);
make.top.equalTo(self.leftScrollView);
make.bottom.equalTo(self.view).offset(-self.tabBarController.tabBar.height);
}];
}
#pragma mark - CollectionView
- (void) collectionViewSetting {
//布局
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.itemSize = CGSizeMake(Size(72),Size(52));
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.minimumLineSpacing = 1;
flowLayout.minimumInteritemSpacing = 1;
//创建collectionView
self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,0,kMainScreenWidth,kMainScreenHeight) collectionViewLayout:flowLayout];
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.scrollEnabled = NO;//appCuttingLineColor
self.collectionView.backgroundColor = [UIColor appBackgroundColor];
[self.contentScrollView addSubview:self.collectionView];
//注册cell
[self.collectionView registerClass:[ZTRoomInfoCollectionViewCell class] forCellWithReuseIdentifier:@"RoomInfoCell"];
}
- (void) topCollectionViewSetting {
//布局
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.itemSize = CGSizeMake(Size(72),Size(44));
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
flowLayout.minimumLineSpacing = 1;
flowLayout.minimumInteritemSpacing = 1;
//创建collectionView
self.topScrollView = [[UICollectionView alloc]initWithFrame:CGRectMake(Size(73),0,kMainScreenWidth,Size(44)) collectionViewLayout:flowLayout];
self.topScrollView.showsHorizontalScrollIndicator = NO;
self.topScrollView.showsVerticalScrollIndicator = NO;
self.topScrollView.delegate = self;
self.topScrollView.dataSource = self;
self.topScrollView.scrollEnabled = NO;
self.topScrollView.backgroundColor = [UIColor appBackgroundColor];
[self.view addSubview:self.topScrollView];
[self.topScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.codeLabel.mas_right).offset(1);
make.top.equalTo(self.headView.mas_bottom);
make.right.equalTo(self.view);
make.height.mas_equalTo(Size(44));
}];
//注册cell
[self.topScrollView registerClass:[ZTRoomTitleCollectionViewCell class] forCellWithReuseIdentifier:@"RoomTimeCell"];
}
- (void) leftCollectionViewSetting {
//布局
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
flowLayout.itemSize = CGSizeMake(Size(72),Size(52));
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
flowLayout.minimumLineSpacing = 1;
flowLayout.minimumInteritemSpacing = 1;
//创建collectionView
self.leftScrollView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,Size(45),Size(72),kMainScreenHeight) collectionViewLayout:flowLayout];
self.leftScrollView.showsHorizontalScrollIndicator = NO;
self.leftScrollView.showsVerticalScrollIndicator = NO;
self.leftScrollView.delegate = self;
self.leftScrollView.dataSource = self;
self.leftScrollView.scrollEnabled = NO;
self.leftScrollView.backgroundColor = [UIColor appBackgroundColor];
[self.view addSubview:self.leftScrollView];
[self.leftScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view);
make.top.equalTo(self.codeLabel.mas_bottom).offset(1);
make.width.mas_equalTo(Size(72));
make.bottom.equalTo(self.view).offset(-self.tabBarController.tabBar.height);
}];
//注册cell
[self.leftScrollView registerClass:[ZTRoomTitleCollectionViewCell class] forCellWithReuseIdentifier:@"RoomNameCell"];
}
#pragma mark - collectionView代理
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (collectionView == self.collectionView) {
NSInteger roomCount = self.leftArray.count;
NSInteger day = [YFWLDateManager totaldaysInMonth:self.currentDate];
self.contentScrollView.contentSize = CGSizeMake(Size(72)*day+day-1, Size(52)*(roomCount-1)+roomCount-1);
self.collectionView.frame = CGRectMake(0,0,Size(72)*day+day-1,Size(52)*(roomCount)+roomCount-1);
return roomCount*day;
}
if (collectionView == self.leftScrollView) {
return self.leftArray.count;
}
return [YFWLDateManager totaldaysInMonth:self.currentDate];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (collectionView == self.leftScrollView) {
ZTRoomTitleCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomNameCell" forIndexPath:indexPath];
cell.backgroundColor = [UIColor colorWithRGB:Color(FAFAFA)];
if (self.leftArray.count > indexPath.row) {
cell.roomNameLabel.text = @"大床房";
cell.roomNumberLabel.text = @"520";
}
return cell;
}
if (collectionView == self.topScrollView) {
ZTRoomTitleCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomTimeCell" forIndexPath:indexPath];
cell.userInteractionEnabled = NO;
cell.backgroundColor = [UIColor appHeadBgColor];
cell.roomNameLabel.font = [UIFont systemFontOfSize:Size(14)];
cell.roomNameLabel.text = [self currentMD:indexPath];
cell.roomNumberLabel.font = [UIFont systemFontOfSize:Size(12)];
cell.roomNumberLabel.text = [self weekStr:[self currentMD:indexPath]];
if ([[self weekStr:[self currentMD:indexPath]] isEqualToString:@"今天"]) {
cell.roomNameLabel.textColor = [UIColor appMainColor];
cell.roomNumberLabel.textColor = [UIColor appMainColor];
}else {
cell.roomNameLabel.textColor = [UIColor appGrayTextColor];
cell.roomNumberLabel.textColor = [UIColor appGrayTextColor];
}
return cell;
}
ZTRoomInfoCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomInfoCell" forIndexPath:indexPath];
NSInteger row = indexPath.row / [YFWLDateManager totaldaysInMonth:self.currentDate];
if (row < self.leftArray.count) {
[cell changeStatus:@""];
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
self.lastOffSet = scrollView.contentOffset;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.contentScrollView) {
if (scrollView.contentOffset.x - self.lastOffSet.x != 0) {
[self.topScrollView setContentOffset:CGPointMake(scrollView.contentOffset.x, 0)];
}
if (scrollView.contentOffset.y - self.lastOffSet.y != 0) {
[self.leftScrollView setContentOffset:CGPointMake(0, scrollView.contentOffset.y)];
}
}
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
return UIEdgeInsetsMake(0, 0, 0, 0);
}
#pragma mark - 日期
- (NSString *) currentMD:(NSIndexPath *)indexPath {
NSInteger day = (indexPath.row)%([YFWLDateManager totaldaysInMonth:self.currentDate])+1;
NSDateFormatter *dateformatter=[[NSDateFormatter alloc] init];
[dateformatter setDateFormat:@"MM"];
NSString *month = [dateformatter stringFromDate:self.currentDate];
if (day < 10) {
return [NSString stringWithFormat:@"%@-0%lu",month,day];
}else {
return [NSString stringWithFormat:@"%@-%lu",month,day];
}
}
- (NSString *) weekStr:(NSString *)dateStr {
//需要转换的字符串
NSString *dateString = [NSString stringWithFormat:@"%lu-%@",[YFWLDateManager year:self.currentDate],dateStr];
//设置转换格式
NSDateFormatter *formatter = [[NSDateFormatter alloc] init] ;
[formatter setDateFormat:@"yyyy-MM-dd"];
//NSString转NSDate
NSDate *date=[formatter dateFromString:dateString];
if ([dateString isEqualToString:[formatter stringFromDate:[NSDate date]]]) {
return @"今天";
}
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"EEE"];
NSString *weekStr = [dateFormat stringFromDate:date];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSArray *languages = [defaults objectForKey:@"AppleLanguages"];
NSString *currentLanguage = [languages objectAtIndex:0];
if ([currentLanguage isEqualToString:@"zh_Hans"]) {
NSString *weekRstr = [NSString stringWithFormat:@"周%@",[weekStr substringFromIndex:weekStr.length-1]];
return weekRstr;
}else {
return weekStr;
}
}
实现效果gif
日历的实现
效果图
核心方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return 42;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
ZTPriceMgmCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PriceMgmCell" forIndexPath:indexPath];
NSInteger daysInThisMonth = [YFWLDateManager totaldaysInMonth:_currentDate];
NSInteger firstWeekday = [YFWLDateManager firstWeekdayInThisMonth:_currentDate];
NSInteger day = 0;
NSInteger i = indexPath.row;
cell.topView.backgroundColor = [UIColor whiteColor];
cell.boView.backgroundColor = [UIColor whiteColor];
cell.selected = NO;
if (i < firstWeekday) {
[cell.dateLabel setText:@""];
cell.userInteractionEnabled = NO;
cell.boView.hidden = YES;
}else if (i > firstWeekday + daysInThisMonth - 1){
[cell.dateLabel setText:@""];
cell.userInteractionEnabled = NO;
cell.boView.hidden = YES;
}else{
day = i - firstWeekday + 1;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *dayStr = [NSString stringWithFormat:@"%lu",day];
[cell.dateLabel setText:dayStr];
if (day < 10) {
dayStr = [NSString stringWithFormat:@"0%lu",day];
}
NSInteger month = [YFWLDateManager month:self.currentDate];
NSString *selectDate = [NSString stringWithFormat:@"%lu-%lu-%@",[YFWLDateManager year:self.currentDate],month,dayStr];
if (month < 10) {
selectDate = [NSString stringWithFormat:@"%lu-0%lu-%@",[YFWLDateManager year:self.currentDate],month,dayStr];
}
NSComparisonResult result = [[dateFormatter dateFromString:self.startDate] compare:[dateFormatter dateFromString:selectDate]];
if (result == NSOrderedDescending) {
cell.userInteractionEnabled = NO;
cell.boView.hidden = YES;
}else if (result == NSOrderedSame) {
cell.userInteractionEnabled = NO;
cell.boView.hidden = NO;
cell.selected = YES;
cell.priceLabel.text = @"开始";
cell.priceLabel.textColor = [UIColor appMainColor];
}else {
cell.boView.hidden = YES;
}
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSInteger firstWeekday = [YFWLDateManager firstWeekdayInThisMonth:_currentDate];
NSInteger day = 0;
NSInteger i = indexPath.row;
day = i - firstWeekday + 1;
NSString *dayStr = [NSString stringWithFormat:@"%lu",day];
if (day < 10) {
dayStr = [NSString stringWithFormat:@"0%lu",day];
}
NSInteger month = [YFWLDateManager month:self.currentDate];
NSString *selectDate = [NSString stringWithFormat:@"%lu-%lu-%@",[YFWLDateManager year:self.currentDate],month,dayStr];
if (month < 10) {
selectDate = [NSString stringWithFormat:@"%lu-0%lu-%@",[YFWLDateManager year:self.currentDate],month,dayStr];
}
NSComparisonResult result = [[dateFormatter dateFromString:self.startDate] compare:[dateFormatter dateFromString:selectDate]];
if (result == NSOrderedDescending || result == NSOrderedSame) {
[YFWLHUDManager showInfoMessage:@"不能小于或等于开始时间" duration:1.6];
}else {
if (self.ReverseValueBlock) {
self.ReverseValueBlock(selectDate);
}
[self leftButtonClick];
}
}
搜索框设计
- (void) setupSearchBar {
self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, kMainScreenWidth-Size(50), Size(30))];
self.searchBar.placeholder = @"手机号/订单号";
[self.searchBar setValue:@"取消" forKey:@"_cancelButtonText"]; //取消设置为中文
self.searchBar.keyboardType = UIKeyboardTypeDefault;
self.searchBar.searchBarStyle = UISearchBarStyleProminent;
self.searchBar.delegate = self;
self.searchBar.tintColor = [UIColor whiteColor];
self.searchBar.barTintColor = [UIColor appBackgroundColor];
self.searchBar.returnKeyType = UIReturnKeySearch;
UIView* backgroundView = [self.searchBar subViewOfClassName:@"_UISearchBarSearchFieldBackgroundView"];
backgroundView.layer.cornerRadius = Size(15);
backgroundView.clipsToBounds = YES;
self.navigationItem.titleView = self.searchBar;
}
去除NSArray中的重复对象
NSArray *newArr = [oldArr valueForKeyPath:@“@distinctUnionOfObjects.self"];
防止离屏渲染为image添加圆角
// image分类
- (UIImage *)circleImage {
// NO代表透明
UIGraphicsBeginImageContextWithOptions(self.size, NO, 1);
// 获得上下文
CGContextRef ctx = UIGraphicsGetCurrentContext();
// 添加一个圆
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
// 方形变圆形
CGContextAddEllipseInRect(ctx, rect);
// 裁剪
CGContextClip(ctx);
// 将图片画上去
[self drawInRect:rect];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
上线的问题综述
- Does your application access any paid content?
答: NO - Who is the target audience?
答: 需要使用此工具的用户 - How do users obtain an account?
答: 一个用户注册一个账号,创建一个企业或油厂,此账号作为Agent账号
答: 其他用户注册账号,申请加入到一个企业或油厂,Agent 审核是否同意此账号加入,并给予分配角色 - Is this app meant for internal distribution in your own company, in the company of one target client, or in multiple target clients’ companies?
答: in the company of one target client - In which countries will this app primarily be distributed?
答: 中国 - If this app is meant for internal distribution, will the app be accessible by both internal and external partners? Or will it be exclusive to in-house employees?
答: both internal and external partners by adding them to a project group