Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iPad分组的桌面视图背景颜色?这是怎么一回事?_Ipad_Uitableview_Uicolor - Fatal编程技术网

iPad分组的桌面视图背景颜色?这是怎么一回事?

iPad分组的桌面视图背景颜色?这是怎么一回事?,ipad,uitableview,uicolor,Ipad,Uitableview,Uicolor,我喜欢ipad上我的tableView的新组合背景色。我想在分割控制器右侧的UIViewController的背景上使用相同的颜色 有人知道这是什么颜色吗?这似乎是一个轻微的渐变。这些都是现成的纹理颜色,UIColor上的静态方法: + (UIColor *)lightTextColor; // for a dark background + (UIColor *)darkTextColor; // for a light backg

我喜欢ipad上我的tableView的新组合背景色。我想在分割控制器右侧的UIViewController的背景上使用相同的颜色


有人知道这是什么颜色吗?这似乎是一个轻微的渐变。

这些都是现成的纹理颜色,UIColor上的静态方法:

+ (UIColor *)lightTextColor;                // for a dark background
+ (UIColor *)darkTextColor;                 // for a light background
+ (UIColor *)groupTableViewBackgroundColor;
+ (UIColor *)viewFlipsideBackgroundColor;
+ (UIColor *)scrollViewTexturedBackgroundColor __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_2);

它不是一种颜色,而是带有渐变图像的
UIImageView

UIImageView* imageView = (UIImageView*) self.tableView.backgroundView;
NSString* file = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Test.png"];
NSData* data = UIImagePNGRepresentation(imageView.image);
[data writeToFile:file atomically:YES];

以下自定义视图控制器代码基于Lutz的答案和的答案创建表视图背景视图的副本。但是,自动旋转存在一个问题,下面的第二个代码段将解决这个问题

// You also need to link against QuartzCore.framework
#import <QuartzCore/QuartzCore.h>

- (void) loadView
{
  CGRect mainViewFrame = [self mainViewFrame];
  self.view = [[[UIView alloc] initWithFrame:mainViewFrame] autorelease];
  CAGradientLayer* gradient = [CAGradientLayer layer];
  gradient.frame = self.view.bounds;
  UIColor* startColor = [UIColor colorWithRed:226.0/255.0 green:229.0/255.0 blue:234.0/255.0 alpha:1.0];
  UIColor* endColor = [UIColor colorWithRed:208.0/255.0 green:210.0/255.0 blue:216.0/255.0 alpha:1.0];
  // Cast to (id) is necessary to get rid of a compiler warning
  gradient.colors = [NSArray arrayWithObjects:(id)startColor.CGColor, (id)endColor.CGColor, nil];
  // Inserting at index position 0 ensures that the gradient is drawn
  // in the background even if the view already has subviews or other
  // sublayers
  [view.layer insertSublayer:gradient atIndex:0];

  // add more subviews
}

- (CGRect) mainViewFrame
{
  // add your frame calculating code here
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
  [UIView animateWithDuration:duration
                        delay:0
                      options:UIViewAnimationCurveLinear
                   animations:^{
                     ((CALayer*)[self.view.layer.sublayers objectAtIndex:0]).frame = self.view.bounds;
                   }
                   completion:NULL];
}
我最喜欢这个代码,因为

  • 它能自动清洁地旋转
  • 没有处理自动旋转的自定义代码
  • 与梯度相关的函数可以重构为一个单独的实用程序类,以使它们更易于重用

我只是把它扔到这里,但是如果你可以在某个地方使用SVG(比如在网页中,或者在使用某种SVG核心图形库的应用程序中),我知道有一些存在,但这不是理想的解决方案),我有以下代码:

<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">
    <linearGradient id="g146" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%">
        <stop stop-color="#E2E5EA" offset="0" />
        <stop stop-color="#D1D3D9" offset="1" />
    </linearGradient>
    <rect x="0" y="0" width="1" height="1" fill="url(#g146)" />
</svg>


使用DigitalColor Meter应用程序(我对苹果应用程序来说是个糟糕的名字)创建,Xcode 4.5ß4和

[UIColor COLOR WITHRED:0.953 green:0.953 blue:0.953 alpha:1]/#F3/

我已经知道这些,我想苹果没有提供。这是一个渐变,因此,我不能仅对颜色进行采样并使用该值。在4.3 iPad模拟器中执行该代码生成的.png图像具有以下属性:大小=1x64,顶部像素RGB=0xe2e5ea(226229234),底部像素RGB=0xd0d2d8(208、210、216)。
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">
    <linearGradient id="g146" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%">
        <stop stop-color="#E2E5EA" offset="0" />
        <stop stop-color="#D1D3D9" offset="1" />
    </linearGradient>
    <rect x="0" y="0" width="1" height="1" fill="url(#g146)" />
</svg>