5 Star 14 Fork 3

67 / LXR_BaiSi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

#LXR_BaiSi

BSBDJ 百思不得姐相关知识点

####解决图片渲染问题

  • 方法1.解决图片渲染问题
    UIImage* image = [UIImage imageNamed:@"tabBar_essence_click_icon"];
//设置image模式是原始效果,不要渲染
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc1.tabBarItem.selectedImage = image;
  • 方法2.解决图片渲染问题

解决图片渲染问题

####修改项目名称

修改项目名称

####通过appearance同一设置所有UITabBarItem的文字属性


    NSMutableDictionary* attrs = [NSMutableDictionary new];
    //文字 字体大小
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    //文字 Foreground前景颜色
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];

    NSMutableDictionary* selectesAttrs = [NSMutableDictionary new];
    selectesAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    selectesAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];


    UITabBarItem* item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectesAttrs forState:UIControlStateSelected];

1

####设置cell默认选中第一行

 //设置左边列表cell默认选中首行
    [self.LeftTableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionTop];

####李明杰第三方转模型框架使用

//通过数组responseObject[@"list"]进行转模型LXRRecommendLeftModel到LeftDataArray数组里
        self.LeftDataArray = [LXRRecommendLeftModel mj_objectArrayWithKeyValuesArray:responseObject[@"list"]];

####重写方法

#pragma mark - 重写选中方法,系统默认选中将所有子控件显示为高亮状态---------重点
//selected会打印出选中第几组第几行信息
/**可以在这个方法中监听cell的选中和取消选中*/
-(void)setSelected:(BOOL)selected animated:(BOOL)animated{

    [super setSelected:selected animated:animated];

    self.SelctedView.hidden = !selected;

    //设置文字颜色,如果是选中状态是红色,如果不是就是正常颜色
    self.textLabel.textColor = selected ? LXR_RGB_Color(219, 21, 26) : LXR_RGB_Color(78, 78,78);

    //设置正常状态下文本颜色
    //self.textLabel.textColor = LXR_RGB_Color(78, 78, 78);
    //默认选中cell时textLable就会变成高亮颜色
    //self.textLabel.highlightedTextColor = LXR_RGB_Color(219, 21, 26);

}

####pch文件设置

//调试
#ifdef DEBUG
#define LXRLog(...) NSLog(__VA_ARGS__)
#else
#define LXRLog(...)
#endif

//打印执行方法
#define LXRLogFunc LXRLog(@"%s",__func__)

//设置颜色
#define LXR_RGB_Color(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

####自定义NavigationController 重写方法

//可以在这个方法中拦截所有PUSH进来的控制器
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{

    //统一设置控制器返回按钮的文字
    if (self.childViewControllers.count > 0) { //如果push进来的不是第一个控制器
        UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom];

        //设置文字 颜色
        [button setTitle:@"返回" forState:UIControlStateNormal];
        [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];

        //设置按钮图片
        [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal];
        [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted];

        //设置按钮大小,一定要设置大小,不然显示不出来
        button.Size = CGSizeMake(60, 30);

        //让按钮内容的所有内容左对齐
        //button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        //根据大小填充 建议使用
        [button sizeToFit];

        //设置按钮贴着屏幕左边  ---------重点!!!
        button.contentEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);


        //添加点击事件  返回界面功能
        [button addTarget:self action:@selector(Back) forControlEvents:UIControlEventTouchUpInside];

        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        //当push下一界面的时候,隐藏tabBar
        viewController.hidesBottomBarWhenPushed = YES;
    }

    //这句super的push要放在后面,让viewController可以覆盖上面设置的leftBarButtonItem
    [super pushViewController:viewController animated:animated];
}

####重写initialize方法 作用

#pragma mark - 设置主题 这个方法只调用一次
+(void)initialize{
    //通过appearance同一设置所有UITabBarItem的文字属性
    NSMutableDictionary* attrs = [NSMutableDictionary new];
    //文字 字体大小
    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:12];
    //文字 Foreground前景颜色
    attrs[NSForegroundColorAttributeName] = [UIColor grayColor];

    NSMutableDictionary* selectesAttrs = [NSMutableDictionary new];
    selectesAttrs[NSFontAttributeName] = attrs[NSFontAttributeName];
    selectesAttrs[NSForegroundColorAttributeName] = [UIColor darkGrayColor];


    UITabBarItem* item = [UITabBarItem appearance];
    [item setTitleTextAttributes:attrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:selectesAttrs forState:UIControlStateSelected];
}

####重写setFrame和setBounds方法作用

/**
 *  需要重写setFrame和setBounds方法作用:
 *  重新布局cell,拦截设置方法后进行重新赋值,别人无法改变
 */
-(void)setFrame:(CGRect)frame{
    //cell效果,x往右移动10,宽度减少2倍的x,高度减少1
    frame.origin.x = 10;
    frame.size.width -= 2*frame.origin.x;
    frame.size.height -= 1;

    [super setFrame:frame];

}

-(void)setBounds:(CGRect)bounds{
    //cell效果,x往右移动10,宽度减少2倍的x,高度减少1
    bounds.origin.x = 10;
    bounds.size.width -= 2*bounds.origin.x;
    bounds.size.height -= 1;

    [super setBounds:bounds];
}

####修改UITextField的placeholder颜色

  • 使用属性
@property(nonatomic,copy)   NSAttributedString     *attributedPlaceholder;

// 文字属性
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor grayColor];

// NSAttributedString : 带有属性的文字(富文本技术)
NSAttributedString *placeholder = [[NSAttributedString alloc] initWithString:@"手机号" attributes:attrs];
self.phoneField.attributedPlaceholder = placeholder;

NSMutableAttributedString *placehoder = [[NSMutableAttributedString alloc] initWithString:@"手机号"];
[placehoder setAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]} range:NSMakeRange(0, 1)];
[placehoder setAttributes:@{
                            NSForegroundColorAttributeName : [UIColor yellowColor],
                            NSFontAttributeName : [UIFont systemFontOfSize:30]
                            } range:NSMakeRange(1, 1)];
[placehoder setAttributes:@{NSForegroundColorAttributeName : [UIColor redColor]} range:NSMakeRange(2, 1)];
self.phoneField.attributedPlaceholder = placehoder;
  • 重写方法
- (void)drawPlaceholderInRect:(CGRect)rect
{
    [self.placeholder drawInRect:CGRectMake(0, 10, rect.size.width, 25) withAttributes:@{
                                                       NSForegroundColorAttributeName : [UIColor grayColor],
                                                       NSFontAttributeName : self.font}];
}
  • 使用KVC
[self setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];

运行时(Runtime)

  • 苹果官方一套C语言库
  • 能做很多底层操作(比如访问隐藏的一些成员变量\成员方法....)
  • 访问成员变量举例
unsigned int count = 0;

// 拷贝出所有的成员变量列表
Ivar *ivars = class_copyIvarList([UITextField class], &count);

for (int i = 0; i<count; i++) {
    // 取出成员变量
    // Ivar ivar = *(ivars + i);
    Ivar ivar = ivars[i];

    // 打印成员变量名字
    XMGLog(@"%s", ivar_getName(ivar));
}

// 释放
free(ivars);

ivars

利用pod trunk发布程序


注册
  • pod trunk register 邮箱 '用户名' --description='电脑描述'
查收邮件
接下来查看个人信息
  • pod trunk me
  - Name:     MJ Lee
  - Email:    xxxxxx@qq.com
  - Since:    January 28th, 03:53
  - Pods:     None
  - Sessions:
    - January 28th, 04:28 - June 5th, 04:34. IP: xxx.xxx.xxx.xxx Description: Macbook Pro
  • 中间可能遇到这种错误
NoMethodError - undefined method 'last' for #<Netrc::Entry:0x007fc59c246378>
  • 这时候需要尝试更新gem源或者pod
    • sudo gem update --system
    • sudo gem install cocoapods
    • sudo gem install cocospods-trunk
创建podspec文件
  • 接下来需要在项目根路径创建一个podspec文件来描述你的项目信息
    • pod spec cretae 文件名
    • 比如pod spec cretae MJExtension就会生成一个MJExtension.podspec
填写podspec内容
Pod::Spec.new do |s|
  s.name         = "MJExtension"
  s.version      = "0.0.1"
  s.summary      = "The fastest and most convenient conversion between JSON and model"
  s.homepage     = "https://github.com/CoderMJLee/MJExtension"
  s.license      = "MIT"
  s.author             = { "MJLee" => "xxxxx@qq.com" }
  s.social_media_url   = "http://weibo.com/exceptions"
  s.source       = { :git => "https://github.com/CoderMJLee/MJExtension.git", :tag => s.version }
  s.source_files  = "MJExtensionExample/MJExtensionExample/MJExtension"
  s.requires_arc = true
end
  • 值得注意的是,现在的podspec必须有tag,所以最好先打个tag,传到github
    • git tag 0.0.1
    • git push --tags
检测podspec语法
  • pod spec lint MJExtension.podspec
发布podspec
检测
  • pod setup : 初始化
  • pod repo update : 更新仓库
  • pod search MJExtension
仓库更新
  • 如果仓库更新慢,可以考虑更换仓库镜像
    • pod repo remove master
    • pod repo add master http://git.oschina.net/akuandev/Specs.git

UIMenuController的示例

UIMenuController

UIMenuController须知

  • 默认情况下, 有以下控件已经支持UIMenuController
    • UITextField
    • UITextView
    • UIWebView

让其他控件也支持UIMenuController(比如UILabel)

  • 自定义UILabel
  • 重写2个方法
/**
 * 让label有资格成为第一响应者
 */
- (BOOL)canBecomeFirstResponder
{
    return YES;
}

/**
 * label能执行哪些操作(比如copy, paste等等)
 * @return  YES:支持这种操作
 */
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(cut:) || action == @selector(copy:) || action == @selector(paste:)) return YES;

    return NO;
}
  • 实现各种操作方法
- (void)cut:(UIMenuController *)menu
{
    // 将自己的文字复制到粘贴板
    [self copy:menu];

    // 清空文字
    self.text = nil;
}

- (void)copy:(UIMenuController *)menu
{
    // 将自己的文字复制到粘贴板
    UIPasteboard *board = [UIPasteboard generalPasteboard];
    board.string = self.text;
}

- (void)paste:(UIMenuController *)menu
{
    // 将粘贴板的文字 复制 到自己身上
    UIPasteboard *board = [UIPasteboard generalPasteboard];
    self.text = board.string;
}
  • 让label成为第一响应者
// 这里的self是label
[self becomeFirstResponder];
  • 显示UIMenuController
UIMenuController *menu = [UIMenuController sharedMenuController];
// targetRect: MenuController需要指向的矩形框
// targetView: targetRect会以targetView的左上角为坐标原点
[menu setTargetRect:self.bounds inView:self];
// [menu setTargetRect:self.frame inView:self.superview];
[menu setMenuVisible:YES animated:YES];

自定义UIMenuController内部的Item

  • 添加item
// 添加MenuItem(点击item, 默认会调用控制器的方法)
UIMenuItem *ding = [[UIMenuItem alloc] initWithTitle:@"顶" action:@selector(ding:)];
UIMenuItem *replay = [[UIMenuItem alloc] initWithTitle:@"回复" action:@selector(replay:)];
UIMenuItem *report = [[UIMenuItem alloc] initWithTitle:@"举报" action:@selector(report:)];
menu.menuItems = @[ding, replay, report];

自定义布局 - 继承UICollectionViewFlowLayout

重写prepareLayout方法

  • 作用:在这个方法中做一些初始化操作
  • 注意:一定要调用[super prepareLayout]

重写layoutAttributesForElementsInRect:方法

  • 作用:
    • 这个方法的返回值是个数组
    • 这个数组中存放的都是UICollectionViewLayoutAttributes对象
    • UICollectionViewLayoutAttributes对象决定了cell的排布方式(frame等)

重写shouldInvalidateLayoutForBoundsChange:方法

  • 作用:如果返回YES,那么collectionView显示的范围发生改变时,就会重新刷新布局
  • 一旦重新刷新布局,就会按顺序调用下面的方法:
    • prepareLayout
    • layoutAttributesForElementsInRect:

重写targetContentOffsetForProposedContentOffset:withScrollingVelocity:方法

  • 作用:返回值决定了collectionView停止滚动时最终的偏移量(contentOffset)
  • 参数:
    • proposedContentOffset:原本情况下,collectionView停止滚动时最终的偏移量
    • velocity:滚动速率,通过这个参数可以了解滚动的方向

####2种方法设置按钮四周圆角

  • 方法1:代码实现

    代码实现

  • 方法2:KVC视图设置

    KVC

####找出类隐藏属性列表方法

  • 查找方法
//导入系统头文件
#import <objc/runtime.h>
@implementation LXRInputField
//此方法只调用一次
+(void)initialize{
    unsigned int count = 0;
    //拷贝出所有成员变量列表
    //查找哪个类就传参输入[类名 class]
    Ivar* ivars = class_copyIvarList([UITextField class], &count);
    //遍历
    for (int i =0; i<count; i++) {
        //取出成员变量
        Ivar ivar = *(ivars + i);
        //打印成员变量名字
        LXRLog(@"%s",ivar_getName(ivar));
    }
    //释放
    free(ivars);
}
  • 打印隐藏属性
2016-06-15 17:44:22.718 01- 百思不得姐[6934:96066] _textStorage
2016-06-15 17:44:22.719 01- 百思不得姐[6934:96066] _borderStyle
2016-06-15 17:44:22.719 01- 百思不得姐[6934:96066] _minimumFontSize
2016-06-15 17:44:22.719 01- 百思不得姐[6934:96066] _delegate
2016-06-15 17:44:22.720 01- 百思不得姐[6934:96066] _background
2016-06-15 17:44:22.720 01- 百思不得姐[6934:96066] _disabledBackground
2016-06-15 17:44:22.720 01- 百思不得姐[6934:96066] _clearButtonMode
2016-06-15 17:44:22.720 01- 百思不得姐[6934:96066] _leftView
2016-06-15 17:44:22.720 01- 百思不得姐[6934:96066] _leftViewMode
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _rightView
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _rightViewMode
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _traits
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _nonAtomTraits
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _fullFontSize
2016-06-15 17:44:22.721 01- 百思不得姐[6934:96066] _padding
2016-06-15 17:44:22.722 01- 百思不得姐[6934:96066] _selectionRangeWhenNotEditing
2016-06-15 17:44:22.722 01- 百思不得姐[6934:96066] _scrollXOffset
2016-06-15 17:44:22.722 01- 百思不得姐[6934:96066] _scrollYOffset
2016-06-15 17:44:22.722 01- 百思不得姐[6934:96066] _progress
2016-06-15 17:44:22.722 01- 百思不得姐[6934:96066] _clearButton
2016-06-15 17:44:22.777 01- 百思不得姐[6934:96066] _clearButtonOffset
2016-06-15 17:44:22.777 01- 百思不得姐[6934:96066] _leftViewOffset
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _rightViewOffset
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _backgroundView
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _disabledBackgroundView
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _systemBackgroundView
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _floatingContentView
2016-06-15 17:44:22.778 01- 百思不得姐[6934:96066] _contentBackdropView
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _fieldEditorBackgroundView
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _fieldEditorEffectView
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _displayLabel
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _placeholderLabel
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _suffixLabel
2016-06-15 17:44:22.779 01- 百思不得姐[6934:96066] _prefixLabel
2016-06-15 17:44:22.802 01- 百思不得姐[6934:96066] _iconView
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _label
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _labelOffset
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _interactionAssistant
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _selectGestureRecognizer
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _inputView
2016-06-15 17:44:22.803 01- 百思不得姐[6934:96066] _inputAccessoryView
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _systemInputViewController
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _atomBackgroundView
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _textFieldFlags
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _deferringBecomeFirstResponder
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _avoidBecomeFirstResponder
2016-06-15 17:44:22.804 01- 百思不得姐[6934:96066] _setSelectionRangeAfterFieldEditorIsAttached
2016-06-15 17:44:22.817 01- 百思不得姐[6934:96066] _animateNextHighlightChange
2016-06-15 17:44:22.817 01- 百思不得姐[6934:96066] _baselineLayoutConstraint
2016-06-15 17:44:22.818 01- 百思不得姐[6934:96066] _baselineLayoutLabel

####比较某时间与目前时间

  • 第一种方法,推荐
-(void)testDate:(NSString*)create_time{
    //日期格式化类
    NSDateFormatter* fmt = [[NSDateFormatter alloc]init];
    //设置日期格式(y:年,M:月,d:天 H:24消失,小写h:12小时,m:分钟,s:秒)
    fmt.dateFormat = @"yyyy-MM-dd HH-mm-ss";

    //当前时间
    NSDate* now = [NSDate date];
    //发帖时间
    NSDate* create = [fmt dateFromString:create_time];
    //日历
    NSCalendar* calendar = [NSCalendar currentCalendar];
    //比较时间
    NSCalendarUnit unit = NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitHour|NSCalendarUnitMinute|NSCalendarUnitSecond;
    NSDateComponents* cmps = [calendar components:unit fromDate:create toDate:now options:0];
    LXRLog(@"%@ %@",create,now);
    LXRLog(@"%zd %zd %zd %zd %zd %zd",cmps.year,cmps.month,cmps.day,cmps.hour,cmps.minute,cmps.second);
    //获得NSDate的每一个元素
    NSInteger year = [calendar component:NSCalendarUnitYear fromDate:now];
    NSInteger month = [calendar component:NSCalendarUnitMonth fromDate:now];
    NSInteger day = [calendar component:NSCalendarUnitDay fromDate:now];

    NSDateComponents* cmps = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now];
}
  • 第二种方法,比较恶心
/**比较时间方法*/
-(void)testDate:(NSString*)create_time{
    //当前时间
    NSDate* now = [NSDate date];
    //发帖时间
    NSDateFormatter* fmt = [[NSDateFormatter alloc]init];
    //设置日期格式(y:年,M:月,d:天 H:24消失,小写h:12小时,m:分钟,s:秒)
    fmt.dateFormat = @"yyyy-MM-dd HH-mm-ss";
    NSDate* create = [fmt dateFromString:create_time];
    //比较时间   NSTimeInterval-->double类型
    NSTimeInterval delta = [now timeIntervalSinceDate:create];

}

####字典转模型 第三方框架使用

  • 替换key值
/**把系统返回的id重新命名新的ID*/
/**第一种方法*/
+(NSDictionary *)mj_replacedKeyFromPropertyName{
    return @{@"ID" : @"id"};
}
/**第二种方法*/
+(NSString *)mj_replacedKeyFromPropertyName121:(NSString *)propertyName{

    if ([propertyName isEqualToString:@"id"]) return @"ID";
    return propertyName;
}

####当设置好Frame,打印结果与设置无问题的时候,达不到预期的效果 2

//首先考虑是系统的自动调整属性-->设置不用自动调整
    self.autoresizingMask = UIViewAutoresizingNone;

####图片保存到相册

  • 系统自带方法 系统自带方法

  • 代码写入

/**保存图片*/
- (IBAction)Save {
    //将图片写入相册
    UIImageWriteToSavedPhotosAlbum(self.imageView.image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
}
/**系统建议命名此方法*/
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
    if (error) {
        [MBProgressHUD showError:@"保存失败!"];
    }else{
        [MBProgressHUD showSuccess:@"保存成功!"];
    }
}

####第三方FaceBook动画框架使用

#if 0
pop和CoreAnimation的区别:
1.CoreAnimation的动画只能添加到Layer上
2.pop的动画能添加到任何对象上
3.pop的底层并非基于CoreAnimation,是基于CADisplayLink
4.CoreAnimation的动画仅仅是表象,并不会真正修改对象的Frame/Size等值
5.pop的动画实时修改对象的属性,真正地修改了对象的属性
#endif
/**pop简介*/
-(void)POPintro{
    //kPOPViewCenter是根据 View 中心点进行动画
    POPSpringAnimation* ani = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
    //动画开始时间(拿到当前时间+自定义时间)
    ani.beginTime = CACurrentMediaTime() + 1.0;
    //弹簧效果设置
    ani.springBounciness = 20;//弹力效果模式是4,范围是[0.20]
    ani.springSpeed = 20;     //速度模式是12,范围是[0,20]
    //包装View开始值--->CGPoint
    ani.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.sloganView.centerX, self.sloganView.centerY)];
    //包装View最终值--->CGPoint
    ani.toValue = [NSValue valueWithCGPoint:CGPointMake(self.sloganView.centerX, 400)];
    //添加动画  key可是储存值,方便查找和释放
    [self.sloganView pop_addAnimation:ani forKey:nil];


    //kPOPLayerPositionY是根据 Layer 中心点进行动画
    POPSpringAnimation* ani = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
    //动画开始时间(拿到当前时间+自定义时间)
    ani.beginTime = CACurrentMediaTime() + 1.0;
    //弹簧效果设置
    ani.springBounciness = 20;//弹力效果模式是4,范围是[0.20]
    ani.springSpeed = 20;     //速度模式是12,范围是[0,20]
    //包装Layer改变范围
    ani.fromValue = @(self.sloganView.layer.position.y);
    ani.toValue = @(400);
    //添加动画  key可是储存值,方便查找和释放
    [self.sloganView pop_addAnimation:ani forKey:nil];
}

####IOS8版本 系统自动计算Cell高度方法

cellHeight

/***重点:cell的高度高度  (IOS8版本以后可以自动设置Cell的高度)****/
    //估计高度
    self.tableView.estimatedRowHeight = 44;
    //系统自带自动根据估计高度计算Cell合适的高度
    self.tableView.rowHeight = UITableViewAutomaticDimension;

####设置状态栏方法

  • 1.info文件修改设置 info文件修改设置
  • 2.代码设置状态 输入图片说明

####得到按钮有图片时的Size,和图片大小一样

/**得到按钮有图片时的Size,和图片大小一样*/
    addButton.size = [UIImage imageNamed:@"tag_add_icon"].size;
    addButton.size = [addButton imageForState:UIControlStateNormal].size;
    addButton.size = addButton.currentImage.size;

重点!!!找出上一界面的导航控制器(Push和Modal两种方法)

  • 通过Push
// 如果控制器'a'->通过Push->另一个控制器'b',控制器'b'要拿到'a'导航栏控制器
    // 1.取出当前的TabBarController->通过系统keyWindow的跟控制器拿到
    UITabBarController *tabBarVc = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    // 2.在通过拿到的tabBarVc->通过当前选中的selectedViewController拿到当前所在的导航控制器
    UINavigationController *navVc = (UINavigationController *)tabBarVc.selectedViewController;
    // 3.通过Push到下一界面
    [navVc pushViewController:想要跳转到的控制器 animated:YES];
  • 通过modal
    // 如果控制器'a'->通过modal->另一个控制器'b',控制器'b'要拿到'a'导航栏控制器
    // 根据展示控制器的属性
    //a.presentedViewController -> b控制器
    //b.presentingViewController -> a控制器
    UIViewController* root = [UIApplication sharedApplication].keyWindow.rootViewController;
    UINavigationController* navVc = (UINavigationController*)root.presentedViewController;
    [navVc pushViewController:想要跳转到的控制器 animated:YES];
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2016 ios刘袭锐 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

仿写百思不得姐客户端 展开 收起
Objective-C
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Objective-C
1
https://gitee.com/ios67/LXR_BaiSi.git
git@gitee.com:ios67/LXR_BaiSi.git
ios67
LXR_BaiSi
LXR_BaiSi
master

搜索帮助