UINavigationBar

  • 从 iOS 15 开始,UINavigationBar在控制器中关联滚动视图顶部使用;在iOS15中,UINavigationBar默认是透明的,有滑动时会逐渐变为模糊效果,可以通过改变UINavigationBar.scrollEdgeAppearance属性直接变为模糊效果、配置相关属性-背景、字体等。
    1. // 修改NarBar背景
    2. if (@available(iOS 15.0, *)) {
    3. UINavigationBarAppearance *appearance = [[UINavigationBarAppearance alloc] init];
    4. // 背景色
    5. appearance.backgroundColor = [UIColor blueColor];
    6. // 去掉半透明效果
    7. appearance.backgroundEffect = nil;
    8. // 标题字体颜色及大小
    9. appearance.titleTextAttributes = @{
    10. NSForegroundColorAttributeName : [UIColor whiteColor],
    11. NSFontAttributeName : [UIFont boldSystemFontOfSize:18],
    12. };
    13. // 设置导航栏下边界分割线透明
    14. appearance.shadowImage = [[UIImage alloc] init];
    15. // 去除导航栏阴影(如果不设置clear,导航栏底下会有一条阴影线)
    16. appearance.shadowColor = [UIColor clearColor];
    17. // standardAppearance:常规状态, 标准外观,iOS15之后不设置的时候,导航栏背景透明
    18. self.navigationBar.standardAppearance = appearance;
    19. // scrollEdgeAppearance:被scrollview向下拉的状态, 滚动时外观,不设置的时候,使用标准外观
    20. self.navigationBar.scrollEdgeAppearance = appearance;
    21. }

UITabBar

  • 从 iOS 15 开始, UITabBar 在控制器中关联滚动视图底部时使用UITabBarAppearance.scrollEdgeAppearance配置相关属性-背景、字体等

    1. // 修改tabbar背景
    2. if (@available(iOS 15.0, *)) {
    3. UITabBarAppearance *appearance = [UITabBarAppearance new];
    4. //tabBar背景颜色
    5. appearance.backgroundColor = [UIColor whiteColor];
    6. // 去掉半透明效果
    7. appearance.backgroundEffect = nil;
    8. // tabBaritem title选中状态颜色
    9. appearance.stackedLayoutAppearance.selected.titleTextAttributes = @{
    10. NSForegroundColorAttributeName:KColorFromRGB(0x53A2F8),
    11. NSFontAttributeName:[UIFont systemFontOfSize:12],
    12. };
    13. //tabBaritem title未选中状态颜色
    14. appearance.stackedLayoutAppearance.normal.titleTextAttributes = @{
    15. NSForegroundColorAttributeName:KColorFromRGB(0x7E7E7E),
    16. NSFontAttributeName:[UIFont systemFontOfSize:12],
    17. };
    18. self.tabBar.scrollEdgeAppearance = appearance;
    19. self.tabBar.standardAppearance = appearance;
    20. }

    UITableView

  • 从 iOS 15 开始,TableView 增加sectionHeaderTopPadding属性,默认情况sectionHeaderTopPadding会有22个像素的高度,及默认情况,TableView section header增加22像素的高度

    1. if (@available(iOS 15.0, *)) {
    2. self.tableView.sectionHeaderTopPadding = 0;
    3. }

UIButton

  • 苹果新增了Button特性,支持更多的配置。UIButton.Configuration是一个新的结构体,它指定按钮及其内容的外观和行为。它有许多与按钮外观和内容相关的属性,如cornerStyle、baseForegroundColor、baseBackgroundColor、buttonSize、title、image、subtitle、titlePadding、imagePadding、contentInsets、imagePlacement等

image.png

  1. UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
  2. button.backgroundColor = [UIColor greenColor];
  3. if (@available(iOS 15.0, *)) {
  4. UIButtonConfiguration *conf = [UIButtonConfiguration tintedButtonConfiguration];
  5. conf.cornerStyle = UIButtonConfigurationCornerStyleMedium;
  6. [conf setImagePadding:5];
  7. [conf setTitle:@"大标题"];
  8. [conf setSubtitle:@"副标题"];
  9. [conf setImage:[UIImage imageNamed:@"btnImage.png"]];
  10. conf.imagePlacement = NSDirectionalRectEdgeLeading;
  11. button.configuration = conf;
  12. } else {
  13. // Fallback on earlier versions
  14. }

UIImage

  • 图片的尺寸变化

    • imageByPreparingThumbnailOfSize:
    • prepareThumbnailOfSize: completionHandler
  • 在iOS15中,UIImageWriteToSavedPhotosAlbum存储图片之后的回调不再返回图片了,会返回nil,如果在回调方法里面操作image有可能会直接Crash。

    1. UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);