uiview

Apply gradient on a UIView not working

五迷三道 提交于 2020-05-26 05:04:34
问题 I am trying to add gradient to a UIView programmatically but it is not working. It just appears to have no color at all. I have attached the relevant code as well as a screenshot. Notice the bottom square over which i am applying the gradient. Can someone help me figure out what I'm doing wrong here? let sundayView = UIView() override func viewDidLoad() { super.viewDidLoad() setupViews() setupSundayView() } func setupViews() { sundayView.translatesAutoresizingMaskIntoConstraints = false view

How to create an image of specific size from UIView

笑着哭i 提交于 2020-05-13 22:57:01
问题 I'm working on iOS app which should enable users to create Instagram stories photos and export them to Instagram. Basically app like Unfold, Stellar, Chroma Stories... I've prepared UI where user can select from prepared templates and add to them own photos with filters, labels etc. My question is - what is the best way to export created UIView to bigger Image? I mean how to get the best quality, sharp pixels of labels etc? Because the template view with subviews (added photos, labels...) is

How to create an image of specific size from UIView

て烟熏妆下的殇ゞ 提交于 2020-05-13 22:55:10
问题 I'm working on iOS app which should enable users to create Instagram stories photos and export them to Instagram. Basically app like Unfold, Stellar, Chroma Stories... I've prepared UI where user can select from prepared templates and add to them own photos with filters, labels etc. My question is - what is the best way to export created UIView to bigger Image? I mean how to get the best quality, sharp pixels of labels etc? Because the template view with subviews (added photos, labels...) is

Multiple WKwebkit views in a single view controller not working

拟墨画扇 提交于 2020-04-30 11:03:29
问题 I am not able to load my sub views. I define them as weak WKWebKit outlets. if i do view = tickerView or view = graphView , it works, but it only loads one of them. I want to load both. How would i do this? override func loadView() { tickerView = WKWebView() tickerView.navigationDelegate = self self.view.addSubview(tickerView) graphView = WKWebView() graphView.navigationDelegate = self self.view.addSubview(graphView) } 回答1: Don't add as subView if you are already connect outlet webView as

Get UIView height and use it for its own constraints

♀尐吖头ヾ 提交于 2020-04-16 05:47:12
问题 How can I can the height of my UIView before it is actually presented? This is what I tried: print(wishWishView.frame.size.height) self.view.addSubview(self.wishWishView) wishWishView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true wishWishView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true wishWishConstraint = wishWishView.topAnchor.constraint(equalTo: self.view.bottomAnchor) wishWishConstraint.isActive = true UIView.animate

UILabel Background Color Leaks to Border

一曲冷凌霜 提交于 2020-04-09 04:52:22
问题 I'm creating a UILabel to which I set the background color and corner radius with the following code: self.scoreLabel.backgroundColor = [UIColor DISRed];// custom red` self.scoreLabel.layer.masksToBounds = YES; self.scoreLabel.layer.cornerRadius = self.scoreLabel.frame.size.width/2; self.scoreLabel.layer.borderWidth = 8.0; self.scoreLabel.layer.borderColor = [[UIColor DISNavy] CGColor]; However the background's color seems to be leaking to the edge of the border (see image). Any ideas why?

UILabel Background Color Leaks to Border

有些话、适合烂在心里 提交于 2020-04-09 04:49:10
问题 I'm creating a UILabel to which I set the background color and corner radius with the following code: self.scoreLabel.backgroundColor = [UIColor DISRed];// custom red` self.scoreLabel.layer.masksToBounds = YES; self.scoreLabel.layer.cornerRadius = self.scoreLabel.frame.size.width/2; self.scoreLabel.layer.borderWidth = 8.0; self.scoreLabel.layer.borderColor = [[UIColor DISNavy] CGColor]; However the background's color seems to be leaking to the edge of the border (see image). Any ideas why?

IOS开发之UIView总结

蓝咒 提交于 2020-03-18 19:10:46
3 月,跳不动了?>>> 如果想调用某个类的某个方法可以写成这样,这个方法来自NSObject类 performSelector: performSelector:withObject: performSelector:withObject:withObject: 实际调用 [self performSelector:@selector(displayViews) withObject:nil afterDelay:1.0f]; 有三个方法分别是 //父视图 [self.view superview] //所有子视图 [self.view subviews] //自身的window self.view.window 循环一个视图下面所有视图的方法 NSArray *allSubviews(UIView *aView) { NSArray *results = [aView subviews]; for (UIView *eachView in [aView subviews]) { NSArray *riz = allSubviews(eachView); if (riz) { results = [results arrayByAddingObjectsFromArray:riz]; } } return results; } 循环返回一个APPLICATION里面所有的VIEW

Add Selector to UIButton

我们两清 提交于 2020-03-02 03:31:07
问题 I have ViewController and then two different ViewControllers that extend that main ViewController , one for the iPhone and the other for the iPad. The iPad's ViewController instantiates a separate extended UIView and sets it as its own view. That view has some buttons, which I want to add its selector methods as some methods in the main ViewController . How can this be achieved? So here's a way to visualize this: Main ViewController | iPhone ViewController | iPad ViewController | Some UIView

iOS小技巧--UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框

ⅰ亾dé卋堺 提交于 2020-02-29 22:41:25
UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法 在iOS开发中,任何可见视图都是继承于UIView的。 继承体系中,大部分UIView的属性适用于其任何孩子。 而UIView的layer属性可以绘制UIView的各种效果。其实我们看到的View的动画实际上也是layer在绘制。 1、绘制圆角 cornerView.layer.cornerRadius = 20; cornerView.layer.masksToBounds = YES; masksToBounds防止子元素溢出父视图。 如果一个正方形要设置成圆形,代码为: cornerView.layer.cornerRadius = cornerView.frame.size.height/2; cornerView.layer.masksToBounds = YES; 2、绘制边框 borderView.layer.borderWidth = 1.0; borderView.layer.borderColor = [UIColor blackColor].CGColor; 注意此处使用的是 CGColor 而不是UIColor. 3、绘制阴影 shadowView.layer.shadowColor = [UIColor redColor].CGColor; shadowView