iOS切圆角的方式

ios-头像切圆角的另外两种方式.zip 除了 imageView.layer.cornerRadius = imageView.frame.size.width / 2;另外两种切圆角的方式 技术交流群295276103 立即下载

第一种方法:通过设置layer的属性(同时使用cornerRadius,masksToBounds会造成离屏渲染)

最简单的一种,但是很影响性能,一般在正常的开发中使用很少.
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
//只需要设置layer层的两个属性
//设置圆角
imageView.layer.cornerRadius = imageView.frame.size.width /
//将多余的部分切掉
imageView.layer.masksToBounds = YES;
[self.view addSubview:imageView];

第二种方法:使用CAShapeLayer和UIBezierPath设置圆角(性能相对好)封装 扩展一个 view

#import <UIKit/UIKit.h>
@interface UIView (PCFrame)
/**

  • 设置圆角
    cornerRadii:圆角大小
    corner:那个方向设置圆角
    **/
  • (void)setCornerWithCornerRadii:(CGSize)cornerRadii byRoundingCorners:(UIRectCorner)corner;
    @end

#import “UIView+PCFrame.h”

@implementation UIView (PCFrame)

  • (void)setCornerWithCornerRadii:(CGSize)cornerRadii byRoundingCorners:(UIRectCorner)corner{
    UIBezierPath *maskPath;
    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
    byRoundingCorners:corner
    cornerRadii:cornerRadii];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.bounds;
    maskLayer.path = maskPath.CGPath;

    self.layer.mask = maskLayer;
    }
    @end

iOS设置圆角的4种方法实例(附性能评测) 主要给大家介绍了关于iOS设置圆角的4种方法,并给大家附上了性能评测,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 立即下载

相关推荐

电商平台大数据分析指标

一、五大关键数据分析指标 1.1活跃用户量 活跃用户量是一个基本的指标,有 DAU(日活跃用户)、WAU(周活跃用户)和 MAU(月活跃用户)三个层次; 1.2转化 转化是一个非常重要的指标,电商运营需要关注主路径、次路径甚至精细到每一个品类 / SKU 的转化率; 1.3留存 留存要从不同的时间周期上研究,包括次日留存率、3 日、7 日、30 日留存; 1.4复购 复购则要从 3 个角度去看,复购用户量、复购率和复购金额比; 1.5GMV GMV 是最重要的指标,我们的运营最终是围绕这

默主归沙的博客 4821

iOS一个简单的设置圆角不引起性能问题的分类

原文 写在前面 iOS设置圆角的性能探究已经是一个老生常谈的问题了,众所周知,如果直接使用layer的cornerRadius + masksToBounds虽然可以很方便的完成圆角设置,但会引起离屏渲染,导致性能问题,在列表视图中过多的圆角设置就会导致滑动卡顿,现在主流的方案就是在获取图片的一刻开启异步线程对图片进行相应的圆角处理,把图片处理成想要的图片在返回主线程进行显示,想要便捷的达成此...

weixin_30699443的博客 226

Ubuntu20.04安装Torque-6.1.2单机版(踩坑篇)

说明:PBS排队系统原先是在Centos7安装使用很顺利,但是有客户需求在Ubuntu20.04上使用,着手在Ubuntu20.04安装上安装的时候发现很多报错,并不能顺利安装,网上查找到的教程,有的说是让放弃转slurm,有的是换源安装,但是安装好的版本很低,有许多bug,不是很好用。经过自己慢慢摸索之后,改了部分配置以及源码之后,能够顺利安装,再次记录一下踩坑心得,与大家一起分享学习。如有问题,欢迎大家来撩。...............

华青水上的博客 8091

iOS切圆角

方法一、layer.cornerRadius 第一种方法最简单,通过层对象的cornerRadius属性实现圆角效果,代码如下: view.layer.cornerRadius = 8.0; view.layer.masksToBounds = YES; 缺点是会有2次rending passes。首先off-screen画出带圆角的图,然后在视图上画第二次。 方法二、通

ZZQCSN的博客 399

以太网传输硬件设计大全

1.网线的介绍RJ45由插头和插做组成,也就是我们常说的网口和网线。RJ45 网线插头又称水晶头,共有八芯做成。RJ45网络传输线分为直通线、交叉线和全反线。直通线用于异种网络设备之间的互连,例如,计算机与交换机。交叉线用于同种网络设备之间的互连,例如,计算机与计算机。全反线用于超级终端与网络设备的控制物理接口之间的连接。下面将介绍一下各线的作用和区别。1.直通线:又叫正线或标准线,两端采用568B做线标准,注意两端都是同样的线序且一一对应。直通线是应用最广泛,现在最常用的线。

weixin_45365488的博客 6751

Windows用户必看:如何在WSL中完美安装CosyVoice的ttsfrd依赖(附避坑指南)

本文为Windows用户提供了在WSL中部署CosyVoice语音合成模型并解决其关键依赖ttsfrd的完整指南。文章详细介绍了从WSL环境配置、Python环境搭建、模型下载到ttsfrd深度安装与问题排查的全流程,并针对WSL特有的文件系统、权限和GPU支持问题提供了解决方案,帮助开发者高效攻克部署难题。

dell8的博客 248

iOS给UIView切圆角

UIView切圆角 众所周知,给UIView切圆角有三种方法。 第一种是设置cornerRadius,但是这种切圆角的方式效率比较低,而且需要切四个圆角都要切,有时候不可以满足需求。 第二种使用贝塞尔曲线切圆角,画出一条路径,用mask来遮罩。代码简单,能够切任意一个位置的圆角 第三种就是纯手工,使用CGContextAddArcToPoint函数来画,显然这种效率比较高,但是

李连毛 7241

cesium 综合教程200+【目录】(已包含186篇文章)

cesium示例教程100+旨在为开发者提供简单快捷的,。在每一个示例中,解释相应的API知识点,做到。目录中有链接的为已有文章,没链接的为目标文章,不断更新中…

大剑师兰特的GIS世界 8899

iOS开发 设置单个圆角,设置圆角封装

【代码】iOS开发 设置单个圆角,设置圆角封装。

zhaofahseng的博客 828

【好玩的游戏项目】使用Docker快速部署属于你的RPG网页小游戏

【好玩的游戏项目】使用Docker快速部署属于你的RPG网页小游戏

jks212454的博客 5579

第一章 电力电子仿真软件 PLECS简介

PLECS是瑞士Plexim公司开发的电力电子仿真软件,具有快速仿真、丰富元件库和热分析功能。软件提供单机版和嵌入MATLAB的版本,支持多平台安装且流程简单。首次运行需获取授权文件,提供60分钟演示模式。界面包含模型创建、帮助文档和元件库浏览器等功能区域,操作便捷。该软件是专业高效的电力电子系统仿真工具。

505

ios 控件切圆_iOS切圆角三种方案

iOS切圆角的方式第一种方法:通过设置layer的属性最简单的一种,但是很影响性能,一般在正常的开发中使用很少.UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];//只需要设置layer层的两个属性//设置圆角imageView.layer.cornerRadius ...

weixin_31208627的博客 1147

最佳RANSAC算法拟合矩形的实现(基于PCL库)

最佳RANSAC算法是一种常用的参数估计方法,用于从数据集中拟合出最佳的模型。在计算机视觉和图像处理领域,最佳RANSAC算法常用于拟合几何形状,如矩形。本文将详细介绍如何使用点云库(PCL)中的最佳RANSAC算法来拟合矩形,并提供相应的源代码。

JbPatch的博客 1544

iOS 图片切圆角的另外两种方式

1: UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:imageView.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:imageView.bounds.size]; CAShapeLayer * maskLaye...

banhan7136的博客 265

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

ios view 切上部分圆角_iOS View/Cell切部分圆角的方法

如果是切4个圆角,下面的方法很实用view.layer.cornerRadius = 6;view.clipToBounds = YES;但遇到下图这种需求(第一个Cell顶部切圆角、最后一个Cell底部切圆角,中间的Cell无圆角),实现起来会很繁杂切圆角上图中每一行是一个cell。如果用上述方法实现,恐怕第一个cell和最后一个cell要添加一个View遮盖多余的圆角!偶然看见别人用了Bezi...

weixin_39948277的博客 738

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

ios 控件切圆_iOS常用组件之高效切圆角的方法汇总

前言圆角(RounderCorner)是一种很常见的视图效果,相比于直角,它更加柔和优美,易于接受。但很多人并不清楚如何设置圆角的正确方式和原理。iOS 客户端开发中,经常碰到圆角视图的需求,本文简单总结一下 UIView 及其子类的一些切圆角方法,并且保证避免出现离屏渲染。下面话不多说了,来一起看看详细的介绍吧。UIView(不包括其子类)UIView *view = [[UIView allo...

weixin_39580124的博客 211

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

iOS 切指定圆角,防止离屏渲染

先看下我们做成的效果图,Demo地址对于iOS开发来说,切圆角应该是每个项目中必须用到的。对于常用的切圆角方法@property(nonatomic) BOOL clipsToBounds; // When YES, content and subviews are clipped to the bounds of

super_niuxinhuai的博客 4151

ios 控件切圆_iOS 常用组件-高效切圆角方法总结

前言iOS 客户端开发中,经常碰到圆角视图的需求,本文简单总结一下 UIView 及其子类的一些切圆角方法,并且保证避免出现离屏渲染。UIView(不包括其子类)UIView *view = [[UIView alloc] init];view.backgroundColor = [UIColor blackColor];view.layer.cornerRadius = 3.f;// 以下两行,...

weixin_39854070的博客 214

iOS切圆角的方式 第一种方法:通过设置layer的属性 最简单的一种,但是很影响性能,一般在正常的开发中使用很少. UIImageView *imageView = [[UIImag

iOS切圆角的方式 第一种方法:通过设置layer的属性 最简单的一种,但是很影响性能,一般在正常的开发中使用很少. UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; //只需要设置layer层的两个属性 //设置圆角 image

qq_31292239的博客 651

ios 控件切圆_iOS 切圆角 任意几个角

使用前提是不能使用mansory 得使用frame布局!1.如果是切四个角的圆角,代码示例:self.picImage.layer.cornerRadius = 8;self.picImage.layer.masksToBounds = YES;2.如果是四个角中的某几个角,一个,两个,或者3个,代码示例(切的左下,和右下):UIBezierPath *maskPath = [UIBezierPa...

weixin_42298809的博客 280

iOS 指定位置切圆角不生效,圆角和阴影不能共存问题解决办法

iOS 指定位置切圆角不生效,圆角和阴影不能共存问题解决办法

runwuwushengxiyu的博客 310

ios view 切上部分圆角_iOS 常用组件-高效切圆角方法总结

前言iOS 客户端开发中,经常碰到圆角视图的需求,本文简单总结一下 UIView 及其子类的一些切圆角方法,并且保证避免出现离屏渲染。UIView(不包括其子类)UIView*view=[[UIViewalloc]init];view.backgroundColor=[UIColorblackColor];view.layer.cornerRadius=3.f;//以下两行,...

weixin_39880490的博客 324

iOS 切圆角离屏渲染问题

GPU屏幕渲染有两种方式: 1、On-Screen Rendering(当前屏幕渲染) 指的是GPU的渲染操作是在当前显示的屏幕缓冲区进行。 2、Off-Screen Rendering(离屏渲染) 指的是GPU在当前屏幕缓冲区以外开辟一个缓冲区进行渲染操作。 离屏渲染的代价很高体现在两个方面,1、需要创建一个新的缓冲区。2、上下文切换操作。 会引发离屏渲染的操作: 1、为图层设置遮罩(layer...

qq_32940999的博客 1061
上一篇: xcode自定义代码块
下一篇: 使用performSelector做消息分发
iOS_ZCP
博客等级 码龄10年 1粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值