ios字体大小适应不同屏幕

//根据button高度来设置字体大小

CGFloat dayLabelWidth = (viewWidth-10)/7-1;

    cancelButton = [[UIButton alloc] initWithFrame:CGRectMake(viewWidth/2, viewHeight-dayLabelWidth*1.2, viewWidth/2, dayLabelWidth*1.2)];

    cancelButton.titleLabel.font = [UIFont boldSystemFontOfSize:dayLabelWidth*0.5];

    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];

    cancelButton.backgroundColor = [UIColor grayColor];

    [cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    [cancelButton addTarget:self action:@selector(cancelSelectCurrentDate) forControlEvents:UIControlEventTouchUpInside];

   [self addSubview:cancelButton fixedOn:viewName fixed:true];

posted @ 2016-06-14 10:41  柳仙慧子  阅读(1830)  评论(0编辑  收藏  举报