我想用UIView动画制作改变UITableViewCell高度的动画(将来用弹簧动画制作).
所以我有:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.backgroundColor = [UIColor greenColor];
}
UILabel *viewLabel = [[UILabel alloc] initWithFrame:CGRectMake(10.0f, 10.0f, [[UIScreen mainScreen] bounds].size.width, 40.0f)];
viewLabel.text = @"Test";
viewLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:viewLabel];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView beginUpdates];
[self animateCell:indexPath andTableView:tableView];
[tableView endUpdates];
}
- (void)animateCell:(NSIndexPath*)indexPath andTableView:(UITableView*)tableView
{
[UIView animateWithDuration:1.0f animations: ^ …Run Code Online (Sandbox Code Playgroud) 在CI有
uint32 value = 39434;
uint8 firstByte = (unsigned char)value;
uint8 secondByte = (unsigned char)(value >> 8);
Run Code Online (Sandbox Code Playgroud)
有没有可能在Swift中实现同样的目标?
尝试在SCNRender对象的每个调用渲染中从MTLTexture创建CVPixelBufferRef:
CVPixelBufferLockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags(rawValue: 0))
let bytesPerRow = 4 * Int(textureSizeX)
let region = MTLRegionMake2D(0, 0, Int(textureSizeX), Int(textureSizeY))
var tmpBuffer = CVPixelBufferGetBaseAddress(pixelBuffer!);
offscreenTexture.getBytes(tmpBuffer!, bytesPerRow: bytesPerRow, from: region, mipmapLevel: 0)
CVPixelBufferUnlockBaseAddress(pixelBuffer!, CVPixelBufferLockFlags(rawValue: 0))
Run Code Online (Sandbox Code Playgroud)
然后转换为UIImage以显示在屏幕上
let ciImage = CIImage.init(cvPixelBuffer: pixelBuffer!)
let temporaryContext = CIContext(options: nil)
let tempImage = temporaryContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: textureSizeX, height: textureSizeY))
let uiImage = UIImage.init(cgImage: tempImage!)
Run Code Online (Sandbox Code Playgroud)
但是不显示图像