iOS基本图形绘制--UIBezierPath

本文介绍iOS平台使用UIBezierPath和CoreGraphics进行基本图形绘制的方法,包括线、弧线、三角形等多种图形,并提供了如何在深色背景下设置标题栏为白色的技巧。

BasicGraphics

iOS基本图形绘制, 包括: 线, 弧线, 三角形, 椭圆, 矩形, 圆角矩形, 贝塞尔曲线等. 效果如下图:
wf9


UIBezierPath

官方参考: UIBezierPath
工程剽窃自: [iPhone] UIBezierPath 図形の描画 (Objective-C)
可以创建的UIBezierPath对象有:

+ bezierPath
+ bezierPathWithRect:
+ bezierPathWithOvalInRect:
+ bezierPathWithRoundedRect:cornerRadius:
+ bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:
+ bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:
+ bezierPathWithCGPath:
- bezierPathByReversingPath   

CoreGraphics

这是另一种更加底层的绘制方法.


深色背景下设置标题栏为白色

背景色为黑色, 需设置状态栏(显示信号, 时间, 电量等)为亮色, 有两种方法:

  • Info.plist添加View controller-based status bar appearance, 设置value为NO. 添加
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];  
  • ViewController.m中实现 - (UIStatusBarStyle) preferredStatusBarStyle 方法
- (UIStatusBarStyle) preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

并且在ViewController.m中调用此方法.

[self preferredStatusBarStyle];

(注意删掉Info.plist中的View controller-based status bar appearance项)


Github

BasicGraphics

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值