UIViewContentMode的各种效果

UIViewContentMode的各种效果:

首先它是枚举类型的数据,表示为下所示:

typedef enum {

UIViewContentModeScaleToFill,             // default value
    UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent
    UIViewContentModeScaleAspectFill,     // contents scaled to fill with fixed aspect. some portion of content may be clipped.
    UIViewContentModeRedraw,              // redraw on bounds change (calls -setNeedsDisplay)
    UIViewContentModeCenter,              // contents remain same size. positioned adjusted.
    UIViewContentModeTop,
    UIViewContentModeBottom,
    UIViewContentModeLeft,
    UIViewContentModeRight,
    UIViewContentModeTopLeft,
    UIViewContentModeTopRight,
    UIViewContentModeBottomLeft,
    UIViewContentModeBottomRight,
} UIViewContentMode;

各种展示效果:

默认值是:0,也就是,UIViewContentModeScaleToFill

一个个来理解下吧:

  • UIViewContentModeScaleToFill:表示完全填充在 frame 里。
  • UIViewContentModeScaleAspectFit:保持比例,但都在 frame 内。
  • UIViewContentModeScaleAspectFill:保持比例,且必须填满,但 frame 外也有,所以,frame只会把部分图片显示出来。

其他的是相似的,按照字面意思去理解就OK啦:

  • UIViewContentModeCenter:这个 image 的中心与 frame 的中心重合。
  • UIViewContentModeTop:这个 image 的上边缘与 frame 的上边缘重合。
  • UIViewContentModeBottom:这个 image 的下边缘与 frame 的下边缘重合。
  • UIViewContentModeLeft:这个 image 的左边缘与 frame 的左边缘重合。
  • UIViewContentModeRight:这个 image 的右边缘与 frame 的右边缘重合。
  • UIViewContentModeTopLeft:类似。
  • UIViewContentModeTopRight:类似。
  • UIViewContentModeBottomLeft:类似。
  • UIViewContentModeBottomRight:类似。
时间: 2024-08-29 07:20:33

UIViewContentMode的各种效果的相关文章

UIViewContentMode各类型效果

UIViewContentMode typedef enum {    UIViewContentModeScaleToFill,    UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent    UIViewContentModeScaleAspectFill,     // contents scaled to fill with

UIViewContentMode各类型效果(UIImageView)

UIViewContentMode typedef enum {    UIViewContentModeScaleToFill,    UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent    UIViewContentModeScaleAspectFill,     // contents scaled to fill with

uiviiewcontentmodel

UIViewContentMode各类型效果 UIViewContentMode typedef enum {     UIViewContentModeScaleToFill,     UIViewContentModeScaleAspectFit,      // contents scaled to fit with fixed aspect. remainder is transparent     UIViewContentModeScaleAspectFill,     // con

iOS的GIF动画效果实现

引言:GIF图像格式是常见的一种动态图片格式,无论是在Web端还是在移动端都经常遇到,但是考虑目前iOS还无法原生展现GIF图片,而对于GIF的原生支持暂时也没有像JPG.PNG等图像格式支持得这么全面,因此本文从图片的合成与分解角度来为大家讲解GIF的知识,结合ImageIO框架可以更方便地实现GIF图片的合成与分解. 本文选自<iOS动画--核心技术与案例实战>. GIF在iOS中的使用场景 GIF在iOS中的使用场景有以下三个方面. (1)GIF图片分解为单帧图片. (2)一系列单帧图片

UIViewContentMode 图文解说

在iOS应用开发中我们常常要对视图的contentMode属性进行设置,尤其在使用UIImageView视图时设置这个属性的概率很高.我们知道contentMode的类型是UIViewContentMode的枚举,那么其每个值是什么含义,设置后会有什么效果呢?下面就来总结下. UIViewContentModeLeft 如果将UIImageView对象的contentMode设置为UIViewContentModeLeft,其内部的图片会按照原有的尺寸大小,以垂直居中,水平居左的方式显示.见UI

iOS UIViewContentMode详解

根据定义可以看出 UIViewContentMode 是UIView的属性,所以这里分别对UIImageView.UIView.UILabel.UIButton设置contentMode属性来查看相应效果. 通过测试可以看到,contentMode属性的设置,在视觉上只对UIImageView起作用,对UIView.UILabel.UIButton都不起作用. 对于UIView,因为它的子视图都已经设置了自己的frame,位置是固定的,所以这里contentMode不起作用. 对于UILabel

Swift - 多个mask的动画效果

效果 源码 https://github.com/YouXianMing/Swift-Animations // // TranformFadeView.swift // Swift-Animations // // Created by YouXianMing on 16/8/20. // Copyright © 2016年 YouXianMing. All rights reserved. // import UIKit enum TranformFadeViewAnimatedType :

如何创建一个非常酷的3D效果菜单

http://www.cocoachina.com/ios/20150603/11992.html 原文地址在这里.原文 去年,读者们投票选出了Top5的iOS7最佳动画,当然也很想看到有关这些动画如何实现的教程.这次,我们将会实现Taasky这个app的3D效果的侧滑菜单. 这篇教程比较适合开发经验比较丰富的开发者.因为这篇教程涵盖Autolayout,UIScrollView,viewcontroller容器还有CoreAnimation.这些对于初学者来说都比较陌生,所以如果你之前没有接触

Android 导航条效果实现(六) TabLayout+ViewPager+Fragment

TabLayout 一.继承结构 public class TabLayout extends HorizontalScrollView java.lang.Object ? android.view.View ? android.view.ViewGroup ? android.widget.FrameLayout ? android.widget.HorizontalScrollView ? android.support.design.widget.TabLayout 二.TabLayou