我不确定要搜索什么.关于如何做到这一点的指针将非常感激.
直到现在,我试图通过使用label.textcolor = [UIcolor colorWithPatternImage:…]将模糊图像的一部分设置为背景来复制效果.这也没有考虑背景全黑(或白色)的情况,并导致文本变得不可读.
但这似乎并不合适.
像这样:
这是我尝试过的:
- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; const CGfloat FontSize = 25.f; const Nsstring *text = @"A long-ish string"; CGSize size = [text sizeWithAttributes:@{NSFontAttributename: [UIFont FontWithname:@"Avenir Next" size:FontSize]}]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(80,270,size.wIDth,size.height)]; label.Font = [UIFont FontWithname:@"Avenir Next" size:FontSize]; label.textAlignment = NSTextAlignmentNatural; label.backgroundcolor = [UIcolor clearcolor]; label.text = text; UIImage *image = [UIImage imagenamed:@"wat@2x"]; UIImage *blurredImage = [image applyBlurWithRadius:20.5 tintcolor:[UIcolor clearcolor] saturationDeltaFactor:1.f maskImage:nil]; UIImageVIEw *imageVIEw = [[UIImageVIEw alloc] initWithImage:[blurredImage applyDarkEffect]]; imageVIEw.frame = self.vIEw.bounds; CGfloat imgScale = image.scale; CGRect labelFrame = label.frame; CGRect realRect = CGRectMake(labelFrame.origin.x * imgScale,labelFrame.origin.y * imgScale,labelFrame.size.wIDth * imgScale,labelFrame.size.height * 2.0); CGImageRef labelPatternImage = CGImageCreateWithImageInRect(image.CGImage,realRect); label.textcolor = [UIcolor colorWithPatternImage:[UIImage imageWithCGImage:labelPatternImage scale:2.f orIEntation:UIImageOrIEntationUp]]; CGImageRelease(labelPatternImage); [self.vIEw addSubvIEw:imageVIEw]; [self.vIEw addSubvIEw:label];}
此代码导致
Code Result http://caughtinflux.com/static/result.png
如您所见,这与NC标签不同.
编辑
文本的模糊图像背景应尽可能与实际背景对齐.希望我的代码的模拟器截图有助于理解我所说的内容.
以上是内存溢出为你收集整理的iOS 7通知中心与标签一样全部内容,希望文章能够帮你解决iOS 7通知中心与标签一样所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)