zoukankan      html  css  js  c++  java
  • 将UIImageView改成圆角和圆形

    1、绘制圆角

        cornerView.layer.cornerRadius = 20;
        cornerView.layer.masksToBounds = YES;



    masksToBounds防止子元素溢出父视图。

    如果一个正方形要设置成圆形,代码为:

        cornerView.layer.cornerRadius = cornerView.frame.size.height/2;
        cornerView.layer.masksToBounds = YES;

    2、绘制边框

        borderView.layer.borderWidth = 1.0;
        borderView.layer.borderColor = [UIColor blackColor].CGColor;


    注意此处使用的是CGColor而不是UIColor.

    3、绘制阴影

        shadowView.layer.shadowColor = [UIColor redColor].CGColor;
        shadowView.layer.shadowOffset = CGSizeMake(5.0, 5.0);
        shadowView.layer.shadowOpacity = YES;


    offset为偏移量,为正表示向frame x,y坐标增加的方向偏移。

    opacity为透明度,默认为0,即表示透明的。所以我们要把opacity设置成1或者YES,表示不透明,也可以设置成0.5或者类似的值呈现半透明。

  • 相关阅读:
    全排列(next_permutation)
    Codeforces Round #321 (Div. 2)C(tree dfs)
    cf_ducational Codeforces Round 16_D(gcd)
    cf455a(简单dp)
    cf584a(水题)
    cf112a(水题)
    冒泡排序
    Python内置类型性能分析
    常见时间复杂度
    MongoDB 备份
  • 原文地址:https://www.cnblogs.com/kelejiabing/p/4308419.html
Copyright © 2011-2022 走看看