UI相关

2016-05-19  本文已影响15人  404该页面无法显示
1. button 图标和文字位置设置
//文字
button.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
button.contentHorizontalAlignment =UIControlContentHorizontalAlignmentLeft;```

//图标
[button setImage:[UIImage imageNamed:@"picture_name.png"] forState:UIControlStateNormal];
[button setImageEdgeInsets:UIEdgeInsetsMake(5, 10, 5, 65)];```

2. title的设置
self.tabBarItem.title = @"首页";  //只在没有嵌入navigation时生效
self.title = @"新闻";  //self.tabBarItem.title继承自self.title;
self.navigationItem.title = @"导航";  //如果不设置,和self.title的内容是一样的```
#####3. NavigationBar中间文字属性修改

self.navigationController.navigationBar.titleTextAttributes = @{
NSForegroundColorAttributeName : [UIColor whiteColor],
NSFontAttributeName : [UIFont boldSystemFontOfSize:16]
};

#####4. Label部分文字变色

NSString *str = @"this is a string";
NSMutableAttributedString *noteStr =
[[NSMutableAttributedString alloc] initWithString:str];
NSRange redRange = NSMakeRange(0, 20);
[noteStr addAttribute:NSForegroundColorAttributeName
value:[UIColor redColor]
range:redRange];
[label setAttributedText:noteStr];
[label sizeToFit];

#####5. UISwitch修改大小

//不能设置frame,只能用缩放比例
switch.transform = CGAffineTransformMakeScale(0.75, 0.75);

#####6. 透明NavigationBar

//写法1

#####7. ScrollView顶部图片下拉变大效果

//以下代码作用是图片高度改变,宽度也会改变,因此只需要修改图片高度即可
ImageView.contentMode=UIViewContentModeScaleAspectFill;

上一篇 下一篇

猜你喜欢

热点阅读