swift - 如何正确地将单独的文件添加到 Xcode 项目中?
问题描述
我从事的唯一其他项目不需要额外的文件。我正在尝试按照本教程进行操作,但自动填充只是偶尔发生。我想我错误地向项目添加了一个新文件。
这是我为添加文件所做的工作。
YouTube 视频:https ://www.youtube.com/watch?v=YcDBMMjj0wU&t=199s
代码:
import UIKit
class DrawExamples: UIView {
override func drawRect(rect: CGRect) {
// context is the object used for drawing
let context = UIGraphicsGetCurrentContext()
CGContextSetLineWidth(context, 3.0)
CGContextSetStrokeColorWithColor(context, UIColor.purpleColor().CGColor)
/*
//straight line
CGContextMoveToPoint(context, 30, 30)
CGContextAddLineToPoint(context, 150, 320)
*/
CGContextMoveToPoint(context, 50, 50)
CGContextAddLineToPoint(context, 90, 130)
CGContextAddLineToPoint(context, 180, 100)
CGContextAddLineToPoint(context, 90, 60)
CGContextAddLineToPoint(context, 90, 130)
//Actually draw the path
CGContextStrokePath(context)
}
}
解决方案
推荐阅读
- css - 第二页的 CSS @page 设置
- postgresql - PostgreSQL | 设备上没有剩余空间
- php - Laravel Eloquent 的 Mysql 索引
- java - 持久列表
处于休眠状态 - xamarin.forms - 错误 XF003:Xamarin.Forms 需要 msbuild。不再支持 xbuild
- c# - 缓存 wcf 服务的问题 - “AspNetCacheProfileAttribute 只能用于 GET 操作”
- javascript - 在 php 中使用 javascript var 获取 wordpress 附件
- proxy - 具有公司代理身份验证的 Chrome 无头浏览器无法正常工作
- android - 片段中的轮播错误
- vidyo - Vidyo - 如何设置 logFileName 写入本地文件