iOS code

UIButton *informationCardBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        [informationCardBtn addTarget:self action:@selector(enterehzFilesVC:) forControlEvents:UIControlEventTouchUpInside];

        [informationCardBtn setImage:[UIImage imageNamed:@"个人_未点击"] forState:UIControlStateNormal];

        

        [informationCardBtn sizeToFit];

        UIBarButtonItem *informationCardItem = [[UIBarButtonItem alloc] initWithCustomView:informationCardBtn];

        

        

        UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

        fixedSpaceBarButtonItem.width = 22;

        

        

        UIButton *settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        [settingBtn addTarget:self action:@selector(enterTeamCard:) forControlEvents:UIControlEventTouchUpInside];

        [settingBtn setImage:[UIImage imageNamed:@"商家_未点击"] forState:UIControlStateNormal];

        [settingBtn sizeToFit];

        UIBarButtonItem *settingBtnItem = [[UIBarButtonItem alloc] initWithCustomView:settingBtn];

        

        self.navigationItem.rightBarButtonItems  = @[informationCardItem,fixedSpaceBarButtonItem,settingBtnItem];



UIButton *detailButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 44)];

        [detailButton setImage:[UIImage imageNamed:@"group_detail"] forState:UIControlStateNormal];

        [detailButton addTarget:self action:@selector(showGroupDetailAction) forControlEvents:UIControlEventTouchUpInside];

        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:detailButton];


UIBarButtonItem *leftButton = [[UIBarButtonItem alloc]initWithTitle:@"退出" style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemPressed:)];

    [self.navigationItem setLeftBarButtonItem:leftButton];



dispatch_async(dispatch_get_global_queue(0, 0), ^{

        

        dispatch_async(dispatch_get_main_queue(), ^{

            

        });

    });



NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];//str->data

            NSDictionary *rootDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];

            NSLog(@"NSJSONSerialization=%@", rootDic);


__weak typeof(self)weakSelf = self;


日期转换为时间戳 (日期转换为秒数)

NSDate *date = [NSDate date];

NSLog(@"当前日期为:%@",date);

NSTimeInterval timeStamp= [date timeIntervalSince1970];

NSLog(@"日期转换为时间戳 %@ = %f", date, timeStamp);


时间戳转日期 (秒数转日期)

NSString *timeStamp2 = @"1414956901";

long long int date1 = (long long int)[timeStamp2 intValue];

NSDate *date2 = [NSDate dateWithTimeIntervalSince1970:date1];

NSLog(@"时间戳转日期 %@  = %@", timeStamp2, date2)


NSDate *currentDate = [NSDate date];//获取当前时间,日期

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

[dateFormatter setDateFormat:@"YYYY/MM/dd hh:mm:ss SS"];

NSString *dateString = [dateFormatter stringFromDate:currentDate];

NSLog(@"dateString:%@",dateString);




    if (!_isPhotoChat) {

        // 假设偏移表格高度的20%进行刷新

        if (!_isLoading) { // 判断是否处于刷新状态,刷新中就不执行

        

            // 取内容的高度:

            //    如果内容高度大于UITableView高度,就取TableView高度

            //    如果内容高度小于UITableView高度,就取内容的实际高度

            float height = scrollView.contentSize.height > self.chatTableView.frame.size.height ? self.chatTableView.frame.size.height : scrollView.contentSize.height;

            

            if ((height - scrollView.contentSize.height + scrollView.contentOffset.y) / height > 0.2) {

                // 调用上拉刷新方法

                NSLog(@"调用上拉刷新方法");

            }

            

            if (- scrollView.contentOffset.y / self.chatTableView.frame.size.height > 0.2) {

                // 调用下拉刷新方法

                NSLog(@"调用下拉刷新方法");

                _isLoading = YES;

                [self loadData2];

            }

        }

    }



  1.     //给图层添加背景图片:
             
  2.  //myView.layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage;
              
  3. //将图层的边框设置为圆脚
      
  4. myWebView.layer.cornerRadius = 8;
       
  5. myWebView.layer.masksToBounds = YES;  
  6. //给图层添加一个有色边框
             
  7.  myWebView.layer.borderWidth = 5;
              
  8. myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];

今天记录下 UILabel的高度和宽度自适应,方法特别简单

1 创建category 

.h

+ (CGFloat)getHeightByWidth:(CGFloat)width title:(NSString *)title font:(UIFont*)font;


+ (CGFloat)getWidthWithTitle:(NSString *)title font:(UIFont *)font;

.m

+ (CGFloat)getHeightByWidth:(CGFloat)width title:(NSString *)title font:(UIFont *)font

{


    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, 0)];

    label.text = title;

    label.font = font;

    label.numberOfLines = 0;

    [label sizeToFit];

    CGFloat height = label.frame.size.height;

    return height;

}


+ (CGFloat)getWidthWithTitle:(NSString *)title font:(UIFont *)font {

    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1000, 0)];

    label.text = title;

    label.font = font;

    [label sizeToFit];

    return label.frame.size.width;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值