UIView显示对话

来源:互联网 发布:诺基亚e63下载软件 编辑:程序博客网 时间:2024/05/19 09:14

    float curHeight =20;

    //字体字典修改字典

    //ios7.0

    NSDictionary *dic;

    if (SYSTEMVERSION_7) {

        UIFont *font =[UIFontsystemFontOfSize:17];

    

        dic =[NSDictionarydictionaryWithObjectsAndKeys:font, nil];

    }

   

   for (int i =0; i<arr.count; i++) {

       CGSize size = CGSizeMake(0,0);

        

        if (SYSTEMVERSION_7) {

            size =[arr[i] boundingRectWithSize:CGSizeMake(200,2000) options:NSStringDrawingUsesLineFragmentOrigin |NSStringDrawingUsesFontLeading attributes:diccontext:nil].size;

        }else{

            size = [arr[i] sizeWithFont:[UIFontboldSystemFontOfSize:17]constrainedToSize:CGSizeMake(200,2000)];

        }


       UILabel * label = nil;

       if (i%2 == 0) {

            label = [[UILabelalloc] initWithFrame:CGRectMake(5, curHeight, size.width, size.height)];

        }else{

            label = [[UILabelalloc] initWithFrame:CGRectMake(320-size.width, curHeight, size.width, size.height)];

        }

        label.text = arr[i];

        label.numberOfLines =0;

        [self.windowaddSubview:label];

        [labelrelease];

        curHeight += size.height;

    }


pch文件中

#define SYSTEMVERSION_7 ([[UIDevice currentDevice] systrmVersion].floatValue>7.0);

0 0
原创粉丝点击