我想为 设置圆角半径和阴影UITabBar,但我遇到了问题。这是我的代码
tabBar.barTintColor = .white
tabBar.isTranslucent = false
tabBar.layer.shadowOffset = CGSize(width: 0, height: 5)
tabBar.layer.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 1).cgColor
tabBar.layer.shadowOpacity = 1;
tabBar.layer.shadowRadius = 25;
tabBar.layer.masksToBounds = false
tabBar.isTranslucent = true
tabBar.barStyle = .blackOpaque
tabBar.layer.cornerRadius = 13
tabBar.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
Run Code Online (Sandbox Code Playgroud)
如果我更改tabBar.layer.masksToBounds = false为= true-> 角半径将显示,但阴影不会显示。
所以我有一个简单的UIView,其中包含UILabel.目前,UIView的高度是硬编码的,当UILabel文本足够长以使内容需要比UIView提供的更高时,这是一个问题.
是否有一种简单的方法来计算UIView的适当高度,以显示所包含的UILabel中的所有内容?
谢谢!
我正在尝试AVVideoComposition在视频顶部添加一些文本并保存视频。这是我使用的代码:
我 创建一个AVMutableComposition and AVVideoComposition
var mutableComp = AVMutableComposition()
var mutableVidComp = AVMutableVideoComposition()
var compositionSize : CGSize?
func configureAsset(){
let options = [AVURLAssetPreferPreciseDurationAndTimingKey : "true"]
let videoAsset = AVURLAsset(url: Bundle.main.url(forResource: "Car", withExtension: "mp4")! , options : options)
let videoAssetSourceTrack = videoAsset.tracks(withMediaType: AVMediaTypeVideo).first! as AVAssetTrack
compositionSize = videoAssetSourceTrack.naturalSize
let mutableVidTrack = mutableComp.addMutableTrack(withMediaType: AVMediaTypeVideo, preferredTrackID: kCMPersistentTrackID_Invalid)
let trackRange = CMTimeRangeMake(kCMTimeZero, videoAsset.duration)
do {
try mutableVidTrack.insertTimeRange( trackRange, of: videoAssetSourceTrack, at: kCMTimeZero)
mutableVidTrack.preferredTransform = videoAssetSourceTrack.preferredTransform
}catch { print(error) }
snapshot = …Run Code Online (Sandbox Code Playgroud) 我想从单词的开头删除空格.即我的第一个角色不应该是空格,并且在两个单词之间只有一个空格.我正在尝试很多东西但是不能从开始移除空间.
我的代码是:
在.h
int whitespaceCount;
Run Code Online (Sandbox Code Playgroud)
在.m
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];
if ([string rangeOfCharacterFromSet:whitespace].location != NSNotFound)
{
whitespaceCount++;
if (whitespaceCount > 1)
{
return NO;
}
}
else
{
whitespaceCount = 0;
return YES;
}
}
Run Code Online (Sandbox Code Playgroud)
从上面的代码中,两个单词之间的一个空格是完美的.请建议我如何删除起始空间.提前致谢.
看似简单的事情,其实做起来真的很难。我已经在这里和 SnapKit GitHub 上浏览了多个主题,但未能解决我的问题。
我想要UITableViewCell一个位于中间的标签,让我们从单元格的顶部和底部说 50。
值得一提的是,单元格是以编程方式创建的
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.addSubview(titleLabel)
titleLabel.snp.makeConstraints { (make) -> Void in
make.topMargin.equalToSuperview().offset(50.0)
make.left.equalToSuperview().inset(UIView.getValueScaledByScreenWidthFor(baseValue:10.0))
make.bottomMargin.equalToSuperview().offset(50.0)
}
}
Run Code Online (Sandbox Code Playgroud)
在 ViewController 中,我尝试了两种自动单元格高度的方法:
extension EpisodeViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableViewAutomaticDimension
}
}
Run Code Online (Sandbox Code Playgroud)
和
tableView.estimatedRowHeight = 100
tableView.rowHeight = UITableViewAutomaticDimension
Run Code Online (Sandbox Code Playgroud)
在viewDidLoad()方法中
我得到的是:
这三个单元格中的每一个都应填充“测试” - 相反,它在不调整单元格大小的情况下将标签向下推到相应单元格下方。
尝试了许多不同的组合,例如:
1) 将约束优先级设置为 999 - 没有变化
2) 添加到 contentView 而不是 self - 根本不显示
3) …
我正在使用 an UIPageViewController,我的目的是在单击UIButton其中一个UIViewController. 我已经用谷歌搜索了我的问题并找到了一些类似的线索,但我无法弄清楚答案。
例如,我的第二个按钮UIViewController vc2应将视图更改为vc3。
根页面视图控制器
import UIKit
class RootPageViewController: UIPageViewController, UIPageViewControllerDataSource {
lazy var viewControllerList:[UIViewController] = {
let sb = UIStoryboard(name: "Main", bundle: nil)
let vc1 = sb.instantiateViewController(withIdentifier: "timelineView")
let vc2 = sb.instantiateViewController(withIdentifier: "mainView")
let vc3 = sb.instantiateViewController(withIdentifier: "addView")
return [vc1, vc2, vc3]
}()
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
let secondViewController = viewControllerList[1]
self.setViewControllers([secondViewController], direction: .forward, animated: false, completion: nil)
}
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore …Run Code Online (Sandbox Code Playgroud) 使用UITableviewcell类来显示表格列表的单元格。我想使用“ navigationController?.pushViewController”从一个屏幕重定向到另一个屏幕,但它在表格单元格类中不支持。那么我如何UIViewcontroller使用pushViewController从表格单元格移动。
我的代码是:
class TableCell: UITableViewCell
{
let storyBoard : UIStoryboard = UIStoryboard(name: "SubMain", bundle:nil)
let nextViewController = storyBoard.instantiateViewController(withIdentifier: "DetailReport") as! DetailReport
nextViewController.aryOfResultList = aryForCreateJSONResult
cell.inputViewController?.navigationController?.pushViewController(nextViewController, animated: true)
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用。请给我解决我的问题
uitableview uinavigationcontroller pushviewcontroller ios swift
ios ×6
swift ×6
uitableview ×2
autolayout ×1
avfoundation ×1
ios5 ×1
iphone ×1
snapkit ×1
uitabbar ×1
uitextfield ×1
xcode ×1