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或者类似的值呈现半透明。

  • 相关阅读:
    cocos2dx-基本动画制作
    cocos2dx-CCScrollView的制作
    回调函数的作用
    cocos2dx-Action动作
    cocos2dx-cpptest的结构
    重载函数
    .h和.cpp的用法与区别
    NDK配置之体会
    Cocos2d-x 3.1 内存管理机制
    idea spring boot
  • 原文地址:https://www.cnblogs.com/kelejiabing/p/4308419.html
Copyright © 2011-2022 走看看