我从 Apple 的示例代码中获得了这个直通顶点着色器:
vertex VertexIO vertexPassThrough(device packed_float4 *pPosition [[ buffer(0) ]],
device packed_float2 *pTexCoords [[ buffer(1) ]],
uint vid [[ vertex_id ]])
{
VertexIO outVertex;
outVertex.position = pPosition[vid];
outVertex.textureCoord = pTexCoords[vid];
return outVertex;
}
Run Code Online (Sandbox Code Playgroud)
这适用于 Swift 4/Xcode 10/iOS 12。现在我使用 Swift 5/Xcode 11/iOS 13,我收到此警告:
writable resources in non-void vertex function
Run Code Online (Sandbox Code Playgroud) 将麦克风音频输入添加到AVCaptureSession似乎禁用了UIImpactFeedbackGenerator.
let audioDevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeAudio)
let audioDeviceInput = try AVCaptureDeviceInput(device: audioDevice)
if self.session.canAddInput(audioDeviceInput) {
self.session.addInput(audioDeviceInput)
}
Run Code Online (Sandbox Code Playgroud)
移除音频设备后,将恢复反馈.
这是正常的行为吗?有没有解决的办法?
我注意到视频模式下的iOS相机应用程序和长按缩略图似乎仍然使反馈工作.所以有必要解决这个问题吗?
我正在尝试实现滚动视图,在滚动时捕捉到点.
我看到的所有帖子都是关于在用户结束拖动滚动后'捕捉到一个点'.我想在拖动过程中使其快速捕捉.
到目前为止,我有这个拖动后停止惯性,它工作正常:
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
targetContentOffset.memory = scrollView.contentOffset
}
Run Code Online (Sandbox Code Playgroud)
我尝试了这个,但没有按照预期工作:
var scrollSnapHeight : CGFloat = myScrollView.contentSize.height/10
Run Code Online (Sandbox Code Playgroud)
scrollViewDidScroll:
func scrollViewDidScroll(scrollView: UIScrollView) {
let remainder : CGFloat = scrollView.contentOffset.y % scrollSnapHeight
var scrollPoint : CGPoint = scrollView.contentOffset
if remainder != 0 && scrollView.dragging
{
if self.lastOffset > scrollView.contentOffset.y //Scrolling Down
{
scrollPoint.y += (scrollSnapHeight - remainder)
NSLog("scrollDown")
}
else //Scrolling Up
{
scrollPoint.y -= (scrollSnapHeight - remainder)
}
scrollView .setContentOffset(scrollPoint, animated: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用requestAVAsset 通过UIActivityController共享视频PHAsset.这适用于Messaging,但不适用于AirDrop,表示为"失败".
PHCachingImageManager.default().requestAVAsset(forVideo: asset, options: nil, resultHandler:
{ (givenAsset, audioMix, info) in
let videoAsset = givenAsset as! AVURLAsset
let videoURL = videoAsset.url
DispatchQueue.main.async {
let activityViewController = UIActivityViewController(
activityItems: [videoURL],
applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityType.saveToCameraRoll]
if let popoverPresentationController = activityViewController.popoverPresentationController {
popoverPresentationController.barButtonItem = (sender)
}
self.present(activityViewController, animated: true, completion: nil)
}
})
Run Code Online (Sandbox Code Playgroud)
这似乎适当地提出了UIActivityController并且只适用于某些活动:
希望在导航栏的后退按钮项上拥有自己的自定义字体,这过去对我有用:
let barButtonAttributes = [NSAttributedString.Key.foregroundColor : UIColor.pink,
NSAttributedString.Key.font : UIFont(name: "My-Awesome-Font", size: 18)!]
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributes, for: .normal)
UIBarButtonItem.appearance().setTitleTextAttributes(barButtonAttributes, for: .highlighted)
Run Code Online (Sandbox Code Playgroud)
在iOS 13上,这对我来说已停止工作。有没有解决的办法?
uinavigationbar uinavigationcontroller uibarbuttonitem ios swift
在 iOS 13/14 中,有一种简单的方法可以通过以下方式呈现上下文菜单UIContextMenuInteraction:
anyUIView.addInteraction(UIContextMenuInteraction(delegate: self))
Run Code Online (Sandbox Code Playgroud)
对我来说,问题在于它模糊了整个用户界面。此外,这只能通过长按/触觉触摸来调用。
如果我不想模糊,可以使用操作菜单。如此处所示 https://developer.apple.com/documentation/uikit/menus_and_shortcuts/adopting_menus_and_uiactions_in_your_user_interface
这似乎没有模糊地呈现,但它似乎只附加到 aUIButton或 a UIBarButtonItem。
let infoButton = UIButton()
infoButton.showsMenuAsPrimaryAction = true
infoButton.menu = UIMenu(options: .displayInline, children: [])
infoButton.addAction(UIAction { [weak infoButton] (action) in
infoButton?.menu = infoButton?.menu?.replacingChildren([new items go here...])
}, for: .menuActionTriggered)
Run Code Online (Sandbox Code Playgroud)
有没有办法将上下文菜单附加到长按时调用且不会模糊显示的 UIView 上?
我有一个项目是我在iOS SDK 6中开始的.我使用iOS 7下载了Xcode 5 Beta并成功运行了它.
但是,要提交项目,我需要回到SDK 6和Xcode 4.当我这样做时,我会收到项目中每个XIB文件的以下消息:

我如何解决这个问题,以便我可以从SDK 6和Xcode 4编译和运行?
我试图在UIView上设置遮罩层的动画.
基本上这段代码显示如下图片:
let bounds: CGRect = self.manualWBMaskView!.bounds
let maskLayer: CAShapeLayer = CAShapeLayer()
maskLayer.frame = bounds
maskLayer.fillColor = UIColor.blackColor().CGColor
let screenWith : CGFloat = UIScreen.mainScreen().bounds.width
let roundedRectFrame : CGRect = CGRectMake(self.manualWBMaskView!.bounds.midX - (screenWith/4), self.manualWBMaskView!.bounds.midY - (screenWith/4), screenWith/2, screenWith/2)
let path: UIBezierPath = UIBezierPath(roundedRect:roundedRectFrame, cornerRadius:10 )
path.appendPath(UIBezierPath(rect: bounds))
maskLayer.path = path.CGPath
maskLayer.fillRule = kCAFillRuleEvenOdd
self.manualWBMaskView!.layer.mask = maskLayer
Run Code Online (Sandbox Code Playgroud)
我想让它从全屏到以上位置动画到切口的位置:
我试过UIView动画,没有运气.既然我已经有一个CAShapeLayer,我应该能够动画那个?
编辑**
这是我试过的动画代码,它不起作用:
//Before Animation Make the Mask fill the whole view:
self.manualWBMaskView!.layer.mask = self.manualWBMaskView!.bounds
var duration: NSTimeInterval = 0.8
CATransaction.begin()
CATransaction[kCATransactionAnimationDuration] = Int(duration) …Run Code Online (Sandbox Code Playgroud) 我有一个UIButton的子类,我模糊,看起来很棒:
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.0];
UIVisualEffect *blurEffect;
blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
visualEffectView.frame = self.bounds;
[self insertSubview:visualEffectView atIndex:0];
visualEffectView.userInteractionEnabled = NO;
self.layer.cornerRadius = 23.8;
self.clipsToBounds = YES;
self.titleLabel.font = [UIFont fontWithName:@"DINCondensed-Bold" size:15.0];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
这些按钮必须经常移动(平移),调整大小和缩放,当我执行这些操作时,模糊消失并变为半透明视图.如果我使用框架/中心移动,使用CGAffineTransformation会发生这种情况.
有办法解决这个问题吗?
ios ×8
swift ×6
xcode ×3
avfoundation ×1
cashapelayer ×1
contextmenu ×1
ios6 ×1
ios7 ×1
layer ×1
macos ×1
mask ×1
metal ×1
nstouchbar ×1
paging ×1
phasset ×1
uiaction ×1
uiblureffect ×1
uimenuitem ×1
uiscrollview ×1
uiview ×1
video ×1